Skip to content

Commit

Permalink
make RenameFile() on Windows also replace the file (#2060)
Browse files Browse the repository at this point in the history
* make RenameFile() on Windows also replace the file

* Add MOVEFILE_COPY_ALLOWED to MoveFileExA
  • Loading branch information
rtldg committed May 5, 2024
1 parent d56dc62 commit 908ffdb
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion core/logic/smn_filesystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 908ffdb

Please sign in to comment.