[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) {
|
||||
wchar_t folder[kMaxPath] = {0};
|
||||
auto end = std::wcschr(path.c_str(), xe::kWPathSeparator);
|
||||
while (end) {
|
||||
wcsncpy(folder, path.c_str(), end - path.c_str() + 1);
|
||||
CreateDirectory(folder, NULL);
|
||||
end = wcschr(++end, xe::kWPathSeparator);
|
||||
}
|
||||
size_t pos = 0;
|
||||
do {
|
||||
pos = path.find_first_of(xe::kWPathSeparator, pos + 1);
|
||||
CreateDirectoryW(path.substr(0, pos).c_str(), nullptr);
|
||||
} while (pos != std::string::npos);
|
||||
return PathExists(path);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue