From 11824b3916a197cb83d5d9a1b5027cf945995add Mon Sep 17 00:00:00 2001 From: Eladash Date: Sat, 10 Apr 2021 07:41:55 +0300 Subject: [PATCH] Win32 FS: Improve fs::create_dir --- Utilities/File.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Utilities/File.cpp b/Utilities/File.cpp index b8b754c4f1..21ca74c51d 100644 --- a/Utilities/File.cpp +++ b/Utilities/File.cpp @@ -595,7 +595,15 @@ bool fs::create_dir(const std::string& path) #ifdef _WIN32 if (!CreateDirectoryW(to_wchar(path).get(), NULL)) { - g_tls_error = to_error(GetLastError()); + int res = GetLastError(); + + if (res == ERROR_ACCESS_DENIED && is_dir(path)) + { + // May happen on drives + res = ERROR_ALREADY_EXISTS; + } + + g_tls_error = to_error(res); return false; }