From fd2ca2927eab50a98b9e8a442222a23d6b87718a Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Sat, 15 Feb 2020 23:19:27 +0900 Subject: [PATCH] Common/FileSystem: Fix recursive directory creation --- src/common/file_system.cpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/common/file_system.cpp b/src/common/file_system.cpp index 96322ad37..71233d43b 100644 --- a/src/common/file_system.cpp +++ b/src/common/file_system.cpp @@ -899,15 +899,13 @@ bool FileSystem::CreateDirectory(const char* Path, bool Recursive) // create directories along the path for (i = 0; i < pathLength; i++) { - if (Path[i] == '\\') + if (Path[i] == '\\' || Path[i] == '/') { tempStr[i] = '\0'; if (!CreateDirectoryA(tempStr, nullptr)) { lastError = GetLastError(); - if (lastError == ERROR_ALREADY_EXISTS) // fine, continue to next path segment - continue; - else // anything else is a fail + if (lastError != ERROR_ALREADY_EXISTS) // fine, continue to next path segment return false; } } @@ -1318,9 +1316,7 @@ bool CreateDirectory(const char* Path, bool Recursive) if (mkdir(tempStr, 0777) < 0) { lastError = errno; - if (lastError == EEXIST) // fine, continue to next path segment - continue; - else // anything else is a fail + if (lastError != EEXIST) // fine, continue to next path segment return false; } }