diff --git a/source/init/splash_window.cpp b/source/init/splash_window.cpp index 77b77e1b5..ac8204531 100644 --- a/source/init/splash_window.cpp +++ b/source/init/splash_window.cpp @@ -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); diff --git a/source/init/tasks.cpp b/source/init/tasks.cpp index ccb46e257..bf65648fc 100644 --- a/source/init/tasks.cpp +++ b/source/init/tasks.cpp @@ -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; }