From 9a8d77137cd6b7228fc30bf83e4827c67256f046 Mon Sep 17 00:00:00 2001 From: gibbed Date: Thu, 18 Jul 2019 17:47:25 -0500 Subject: [PATCH] [Base] Fix Windows CreateFolder so it creates the entire path properly. --- src/xenia/base/filesystem_win.cc | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/xenia/base/filesystem_win.cc b/src/xenia/base/filesystem_win.cc index c36197a05..2028a2d9a 100644 --- a/src/xenia/base/filesystem_win.cc +++ b/src/xenia/base/filesystem_win.cc @@ -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); }