mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 14:19:46 -06:00
Fix config file saving on Windows.
This commit is contained in:
@ -244,16 +244,16 @@ bool Rename(const std::string &srcFilename, const std::string &destFilename)
|
|||||||
INFO_LOG(COMMON, "Rename: %s --> %s",
|
INFO_LOG(COMMON, "Rename: %s --> %s",
|
||||||
srcFilename.c_str(), destFilename.c_str());
|
srcFilename.c_str(), destFilename.c_str());
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
auto sf = UTF8ToTStr(srcFilename).c_str();
|
auto sf = UTF8ToTStr(srcFilename);
|
||||||
auto df = UTF8ToTStr(destFilename).c_str();
|
auto df = UTF8ToTStr(destFilename);
|
||||||
// The Internet seems torn about whether ReplaceFile is atomic or not.
|
// The Internet seems torn about whether ReplaceFile is atomic or not.
|
||||||
// Hopefully it's atomic enough...
|
// Hopefully it's atomic enough...
|
||||||
if (ReplaceFile(df, sf, NULL, REPLACEFILE_IGNORE_MERGE_ERRORS, NULL, NULL))
|
if (ReplaceFile(df.c_str(), sf.c_str(), NULL, REPLACEFILE_IGNORE_MERGE_ERRORS, NULL, NULL))
|
||||||
return true;
|
return true;
|
||||||
// Might have failed because the destination doesn't exist.
|
// Might have failed because the destination doesn't exist.
|
||||||
if (GetLastError() == ERROR_FILE_NOT_FOUND)
|
if (GetLastError() == ERROR_FILE_NOT_FOUND)
|
||||||
{
|
{
|
||||||
if (MoveFile(sf, df))
|
if (MoveFile(sf.c_str(), df.c_str()))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
Reference in New Issue
Block a user