mirror of
https://github.com/thunderbrewhq/bc.git
synced 2025-12-12 01:52:30 +00:00
fix(file): fixed bug in recursive CreateDirectory on posix where it skips over the root
This commit is contained in:
parent
ba15fd914f
commit
e813ad0672
1 changed files with 4 additions and 3 deletions
|
|
@ -18,6 +18,7 @@
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
#if defined(WHOA_SYSTEM_LINUX)
|
#if defined(WHOA_SYSTEM_LINUX)
|
||||||
#include <sys/vfs.h>
|
#include <sys/vfs.h>
|
||||||
|
|
@ -461,11 +462,11 @@ bool CreateDirectory(FileParms* parms) {
|
||||||
path++;
|
path++;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto length = path - name;
|
auto length = std::max(static_cast<int32_t>(path - name), 1);
|
||||||
Blizzard::String::Copy(dir, name, length < BC_FILE_MAX_PATH ? length : BC_FILE_MAX_PATH);
|
Blizzard::String::Copy(dir, name, length < BC_FILE_MAX_PATH ? length + 1 : BC_FILE_MAX_PATH);
|
||||||
|
|
||||||
if (!Blizzard::File::IsDirectory(dir)) {
|
if (!Blizzard::File::IsDirectory(dir)) {
|
||||||
if (::mkdir(parms->name, 0777) != 0) {
|
if (::mkdir(dir, 0777) != 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue