From d78c22aa64f63b06b39c644c5d65aee367ec74b4 Mon Sep 17 00:00:00 2001 From: Ron W Moore Date: Tue, 25 Aug 2020 09:44:56 -0400 Subject: 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 --- Source/cmSystemTools.cxx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index b63c318..3cea743 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -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 -- cgit v0.12