From 908ffdb523dda77ded9c383ea1862a813bb8d35e Mon Sep 17 00:00:00 2001 From: rtldg <55846624+rtldg@users.noreply.github.com> Date: Sun, 5 May 2024 22:20:46 +0000 Subject: [PATCH] make RenameFile() on Windows also replace the file (#2060) * make RenameFile() on Windows also replace the file * Add MOVEFILE_COPY_ALLOWED to MoveFileExA --- core/logic/smn_filesystem.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/logic/smn_filesystem.cpp b/core/logic/smn_filesystem.cpp index 3d9b302d..0577bf4d 100644 --- a/core/logic/smn_filesystem.cpp +++ b/core/logic/smn_filesystem.cpp @@ -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