Use MoveFileExW to implement FioRenameFile on Windows

This is to allow renaming over an existing file
This commit is contained in:
Jonathan G Rennison
2024-04-20 20:46:10 +01:00
parent 083d91a582
commit 71227f61d8
2 changed files with 1 additions and 6 deletions

View File

@@ -383,7 +383,7 @@ void FioCreateDirectory(const std::string &name)
bool FioRenameFile(const std::string &oldname, const std::string &newname)
{
#if defined(_WIN32)
return _wrename(OTTD2FS(oldname).c_str(), OTTD2FS(newname).c_str()) == 0;
return MoveFileExW(OTTD2FS(oldname).c_str(), OTTD2FS(newname).c_str(), MOVEFILE_COPY_ALLOWED | MOVEFILE_REPLACE_EXISTING) != 0;
#else
return rename(oldname.c_str(), newname.c_str()) == 0;
#endif