[Base] Fix Windows CreateFolder so it creates the entire path properly.

This commit is contained in:
gibbed 2019-07-18 17:47:25 -05:00
parent 324d28adba
commit 9a8d77137c
1 changed files with 5 additions and 7 deletions

View File

@ -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);
} }