make RenameFile() on Windows also replace the file (#2060)

* make RenameFile() on Windows also replace the file

* Add MOVEFILE_COPY_ALLOWED to MoveFileExA
This commit is contained in:
rtldg 2024-05-05 22:20:46 +00:00 committed by GitHub
parent d56dc62e03
commit 908ffdb523
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -639,7 +639,7 @@ static cell_t sm_RenameFile(IPluginContext *pContext, const cell_t *params)
g_pSM->BuildPath(Path_Game, old_realpath, sizeof(old_realpath), "%s", oldpath);
#ifdef PLATFORM_WINDOWS
return (MoveFileA(old_realpath, new_realpath)) ? 1 : 0;
return (MoveFileExA(old_realpath, new_realpath, MOVEFILE_COPY_ALLOWED | MOVEFILE_REPLACE_EXISTING)) ? 1 : 0;
#elif defined PLATFORM_POSIX
return (rename(old_realpath, new_realpath)) ? 0 : 1;
#endif