From e8f619c44a23ebba06be1fb4442483d481477b81 Mon Sep 17 00:00:00 2001 From: zeromus Date: Fri, 9 Apr 2021 11:43:20 -0400 Subject: [PATCH] winport: fix #442 --- desmume/src/path.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/desmume/src/path.cpp b/desmume/src/path.cpp index 2fcdaec5a..baeb1b691 100644 --- a/desmume/src/path.cpp +++ b/desmume/src/path.cpp @@ -155,11 +155,16 @@ BOOL DirectoryExists(LPCTSTR szPath) void createDirectoryRecursively(std::wstring path) { signed int pos = 0; + std::vector parts; do { pos = path.find_first_of(L"\\/", pos + 1); - CreateDirectoryW(path.substr(0, pos).c_str(), NULL); + parts.push_back(path.substr(0, pos)); } while (pos != std::wstring::npos); + if(parts.size()==0) return; + parts.pop_back(); + for(auto &str : parts) + CreateDirectoryW(str.c_str(), NULL); }