From e813ad06729f16560e0eae67ea303ad22c95e6eb Mon Sep 17 00:00:00 2001 From: superp00t Date: Sun, 30 Mar 2025 22:32:09 -0400 Subject: [PATCH] fix(file): fixed bug in recursive CreateDirectory on posix where it skips over the root --- bc/system/file/posix/Stacked.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/bc/system/file/posix/Stacked.cpp b/bc/system/file/posix/Stacked.cpp index 5d39176..b6c9649 100644 --- a/bc/system/file/posix/Stacked.cpp +++ b/bc/system/file/posix/Stacked.cpp @@ -18,6 +18,7 @@ #include #include #include +#include #if defined(WHOA_SYSTEM_LINUX) #include @@ -461,11 +462,11 @@ bool CreateDirectory(FileParms* parms) { path++; } - auto length = path - name; - Blizzard::String::Copy(dir, name, length < BC_FILE_MAX_PATH ? length : BC_FILE_MAX_PATH); + auto length = std::max(static_cast(path - name), 1); + Blizzard::String::Copy(dir, name, length < BC_FILE_MAX_PATH ? length + 1 : BC_FILE_MAX_PATH); if (!Blizzard::File::IsDirectory(dir)) { - if (::mkdir(parms->name, 0777) != 0) { + if (::mkdir(dir, 0777) != 0) { return false; } }