Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix config file saving on Windows.
  • Loading branch information
comex committed Oct 15, 2013
1 parent b1afb32 commit b11cf1f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Source/Core/Common/Src/FileUtil.cpp
Expand Up @@ -244,16 +244,16 @@ bool Rename(const std::string &srcFilename, const std::string &destFilename)
INFO_LOG(COMMON, "Rename: %s --> %s",
srcFilename.c_str(), destFilename.c_str());
#ifdef _WIN32
auto sf = UTF8ToTStr(srcFilename).c_str();
auto df = UTF8ToTStr(destFilename).c_str();
auto sf = UTF8ToTStr(srcFilename);
auto df = UTF8ToTStr(destFilename);
// The Internet seems torn about whether ReplaceFile is atomic or not.
// 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;
// Might have failed because the destination doesn't exist.
if (GetLastError() == ERROR_FILE_NOT_FOUND)
{
if (MoveFile(sf, df))
if (MoveFile(sf.c_str(), df.c_str()))
return true;
}
#else
Expand Down

0 comments on commit b11cf1f

Please sign in to comment.