aboutsummaryrefslogtreecommitdiff
path: root/zencore/filesystem.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'zencore/filesystem.cpp')
-rw-r--r--zencore/filesystem.cpp18
1 files changed, 13 insertions, 5 deletions
diff --git a/zencore/filesystem.cpp b/zencore/filesystem.cpp
index 0aa478404..1e4a52638 100644
--- a/zencore/filesystem.cpp
+++ b/zencore/filesystem.cpp
@@ -188,13 +188,21 @@ CleanDirectory(const wchar_t* DirPath)
bool
CreateDirectories(const std::filesystem::path& Dir)
{
- std::error_code ErrorCode;
- bool WasCreated = std::filesystem::create_directories(Dir, ErrorCode);
- if (ErrorCode)
+ while (!std::filesystem::is_directory(Dir))
{
- throw std::system_error(ErrorCode, fmt::format("Failed to create directories for '{}'", Dir.string()));
+ if (Dir.has_parent_path())
+ {
+ CreateDirectories(Dir.parent_path());
+ }
+ std::error_code ErrorCode;
+ std::filesystem::create_directory(Dir, ErrorCode);
+ if (ErrorCode)
+ {
+ throw std::system_error(ErrorCode, fmt::format("Failed to create directories for '{}'", Dir.string()));
+ }
+ return true;
}
- return WasCreated;
+ return false;
}
bool