[Base] Fix Windows CreateFolder so it creates the entire path properly.
This commit is contained in:
parent
324d28adba
commit
9a8d77137c
|
@ -45,13 +45,11 @@ bool PathExists(const std::wstring& path) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CreateFolder(const std::wstring& path) {
|
bool CreateFolder(const std::wstring& path) {
|
||||||
wchar_t folder[kMaxPath] = {0};
|
size_t pos = 0;
|
||||||
auto end = std::wcschr(path.c_str(), xe::kWPathSeparator);
|
do {
|
||||||
while (end) {
|
pos = path.find_first_of(xe::kWPathSeparator, pos + 1);
|
||||||
wcsncpy(folder, path.c_str(), end - path.c_str() + 1);
|
CreateDirectoryW(path.substr(0, pos).c_str(), nullptr);
|
||||||
CreateDirectory(folder, NULL);
|
} while (pos != std::string::npos);
|
||||||
end = wcschr(++end, xe::kWPathSeparator);
|
|
||||||
}
|
|
||||||
return PathExists(path);
|
return PathExists(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue