filesystem: Windows SDL_SYS_CreateDirectory should succeed if dir exists.

This commit is contained in:
Ryan C. Gordon 2024-09-27 15:27:25 -04:00
parent 48c3ee2120
commit 94030131de

View File

@ -167,7 +167,16 @@ bool SDL_SYS_CreateDirectory(const char *path)
return false;
}
const DWORD rc = CreateDirectoryW(wpath, NULL);
DWORD rc = CreateDirectoryW(wpath, NULL);
if (!rc && (GetLastError() == ERROR_ALREADY_EXISTS)) {
WIN32_FILE_ATTRIBUTE_DATA winstat;
if (GetFileAttributesExW(wpath, GetFileExInfoStandard, &winstat)) {
if (winstat.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
rc = 1; // exists and is already a directory: cool.
}
}
}
SDL_free(wpath);
if (!rc) {
return WIN_SetError("Couldn't create directory");