mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-03-30 13:05:25 -05:00
fix: ImHex crashing when default folders couldn't get created
This fixes #238
This commit is contained in:
@@ -47,15 +47,31 @@ namespace hex::init {
|
||||
}
|
||||
|
||||
bool createDirectories() {
|
||||
bool result = true;
|
||||
|
||||
std::filesystem::create_directories(hex::getPath(ImHexPath::Patterns)[0]);
|
||||
std::filesystem::create_directories(hex::getPath(ImHexPath::PatternsInclude)[0]);
|
||||
std::filesystem::create_directories(hex::getPath(ImHexPath::Magic)[0]);
|
||||
std::filesystem::create_directories(hex::getPath(ImHexPath::Plugins)[0]);
|
||||
std::filesystem::create_directories(hex::getPath(ImHexPath::Resources)[0]);
|
||||
std::filesystem::create_directories(hex::getPath(ImHexPath::Config)[0]);
|
||||
std::array paths = {
|
||||
ImHexPath::Patterns,
|
||||
ImHexPath::PatternsInclude,
|
||||
ImHexPath::Magic,
|
||||
ImHexPath::Plugins,
|
||||
ImHexPath::Resources,
|
||||
ImHexPath::Config
|
||||
};
|
||||
|
||||
return true;
|
||||
for (auto path : paths) {
|
||||
for (auto &folder : hex::getPath(path)) {
|
||||
try {
|
||||
std::filesystem::create_directories(folder);
|
||||
} catch (...) {
|
||||
result = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!result)
|
||||
getInitArguments().push_back({ "folder-creation-error", { } });
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
bool loadDefaultViews() {
|
||||
@@ -112,14 +128,21 @@ namespace hex::init {
|
||||
}
|
||||
|
||||
bool loadSettings() {
|
||||
ContentRegistry::Settings::load();
|
||||
try {
|
||||
ContentRegistry::Settings::load();
|
||||
} catch (...) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool storeSettings() {
|
||||
ContentRegistry::Settings::store();
|
||||
|
||||
try {
|
||||
ContentRegistry::Settings::store();
|
||||
} catch (...) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user