From 25df65865319387cf3a85afb212d0af9e45076b0 Mon Sep 17 00:00:00 2001 From: WerWolv Date: Wed, 12 Jan 2022 09:02:03 +0100 Subject: [PATCH] fix: ImHex directories not being created correctly --- plugins/libimhex/include/hex/helpers/paths.hpp | 2 +- plugins/libimhex/source/helpers/paths.cpp | 10 ++++++---- source/init/tasks.cpp | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/plugins/libimhex/include/hex/helpers/paths.hpp b/plugins/libimhex/include/hex/helpers/paths.hpp index 0c744b061..f0938ea94 100644 --- a/plugins/libimhex/include/hex/helpers/paths.hpp +++ b/plugins/libimhex/include/hex/helpers/paths.hpp @@ -19,6 +19,6 @@ namespace hex { std::string getExecutablePath(); - std::vector getPath(ImHexPath path); + std::vector getPath(ImHexPath path, bool listNonExisting = false); } \ No newline at end of file diff --git a/plugins/libimhex/source/helpers/paths.cpp b/plugins/libimhex/source/helpers/paths.cpp index 8285a6cc1..08e24385f 100644 --- a/plugins/libimhex/source/helpers/paths.cpp +++ b/plugins/libimhex/source/helpers/paths.cpp @@ -36,7 +36,7 @@ namespace hex { #endif } - std::vector getPath(ImHexPath path) { + std::vector getPath(ImHexPath path, bool listNonExisting) { std::vector result; #if defined(OS_WINDOWS) @@ -195,9 +195,11 @@ namespace hex { } #endif - result.erase(std::remove_if(result.begin(), result.end(), [](const auto& path){ - return !std::filesystem::is_directory(path); - }), result.end()); + if (!listNonExisting) { + result.erase(std::remove_if(result.begin(), result.end(), [](const auto& path){ + return !std::filesystem::is_directory(path); + }), result.end()); + } return result; } diff --git a/source/init/tasks.cpp b/source/init/tasks.cpp index d5b4cd2fd..c89846f39 100644 --- a/source/init/tasks.cpp +++ b/source/init/tasks.cpp @@ -70,7 +70,7 @@ namespace hex::init { }; for (auto path : paths) { - for (auto &folder : hex::getPath(path)) { + for (auto &folder : hex::getPath(path, true)) { try { std::filesystem::create_directories(folder); } catch (...) {