Common/FileSystem: Fix recursive directory creation
This commit is contained in:
parent
89ac06a385
commit
fd2ca2927e
|
@ -899,15 +899,13 @@ bool FileSystem::CreateDirectory(const char* Path, bool Recursive)
|
||||||
// create directories along the path
|
// create directories along the path
|
||||||
for (i = 0; i < pathLength; i++)
|
for (i = 0; i < pathLength; i++)
|
||||||
{
|
{
|
||||||
if (Path[i] == '\\')
|
if (Path[i] == '\\' || Path[i] == '/')
|
||||||
{
|
{
|
||||||
tempStr[i] = '\0';
|
tempStr[i] = '\0';
|
||||||
if (!CreateDirectoryA(tempStr, nullptr))
|
if (!CreateDirectoryA(tempStr, nullptr))
|
||||||
{
|
{
|
||||||
lastError = GetLastError();
|
lastError = GetLastError();
|
||||||
if (lastError == ERROR_ALREADY_EXISTS) // fine, continue to next path segment
|
if (lastError != ERROR_ALREADY_EXISTS) // fine, continue to next path segment
|
||||||
continue;
|
|
||||||
else // anything else is a fail
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1318,9 +1316,7 @@ bool CreateDirectory(const char* Path, bool Recursive)
|
||||||
if (mkdir(tempStr, 0777) < 0)
|
if (mkdir(tempStr, 0777) < 0)
|
||||||
{
|
{
|
||||||
lastError = errno;
|
lastError = errno;
|
||||||
if (lastError == EEXIST) // fine, continue to next path segment
|
if (lastError != EEXIST) // fine, continue to next path segment
|
||||||
continue;
|
|
||||||
else // anything else is a fail
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue