mirror of https://github.com/WerWolv/ImHex.git
fix: ImHex crashing when default folders couldn't get created
This fixes #238
This commit is contained in:
parent
16a0fe4281
commit
b1c597e662
|
@ -45,7 +45,11 @@ namespace hex::init {
|
|||
this->m_currTaskName = name;
|
||||
}
|
||||
|
||||
status = task() && status;
|
||||
try {
|
||||
status = task() && status;
|
||||
} catch (...) {
|
||||
status = false;
|
||||
}
|
||||
|
||||
{
|
||||
std::lock_guard guard(this->m_progressMutex);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue