cmSystemTools: Improve RenameFile on Windows with MOVEFILE_WRITE_THROUGH

Add this flag to tell `MoveFileExW` to flush the rename to disk before
returning.

Issue: #19580
This commit is contained in:
Ron W Moore
2020-08-25 09:44:56 -04:00
committed by Brad King
parent 73f8240ae7
commit d78c22aa64

View File

@@ -885,8 +885,10 @@ void cmSystemTools::InitializeLibUV()
namespace {
bool cmMoveFile(std::wstring const& oldname, std::wstring const& newname)
{
// Use MOVEFILE_REPLACE_EXISTING to replace an existing destination file.
// Use MOVEFILE_WRITE_THROUGH to flush the change to disk before returning.
return MoveFileExW(oldname.c_str(), newname.c_str(),
MOVEFILE_REPLACE_EXISTING);
MOVEFILE_REPLACE_EXISTING | MOVEFILE_WRITE_THROUGH);
}
}
#endif