summaryrefslogtreecommitdiffstats
path: root/Source/cmSystemTools.cxx
diff options
context:
space:
mode:
authorRon W Moore <webbtrail@gmail.com>2020-08-26 01:22:52 (GMT)
committerBrad King <brad.king@kitware.com>2020-08-31 17:03:36 (GMT)
commitb54190a406327e7ebcba62dd90fe03a55dbb6c26 (patch)
tree1e2d6e893fff67d1470357a0c9b3db257535e498 /Source/cmSystemTools.cxx
parent2f8ef095daa6613ca1d37fef496a48a48f74604e (diff)
downloadCMake-b54190a406327e7ebcba62dd90fe03a55dbb6c26.zip
CMake-b54190a406327e7ebcba62dd90fe03a55dbb6c26.tar.gz
CMake-b54190a406327e7ebcba62dd90fe03a55dbb6c26.tar.bz2
cmSystemTools: Teach RenameFile to try for longer on directories
Issue: #19580
Diffstat (limited to 'Source/cmSystemTools.cxx')
-rw-r--r--Source/cmSystemTools.cxx13
1 files changed, 12 insertions, 1 deletions
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx
index 95944a2..69acf92 100644
--- a/Source/cmSystemTools.cxx
+++ b/Source/cmSystemTools.cxx
@@ -809,6 +809,17 @@ WindowsFileRetryInit InitWindowsDirectoryRetry()
return dirInit;
}
+cmSystemTools::WindowsFileRetry GetWindowsRetry(std::wstring const& path)
+{
+ // If we are performing a directory operation, then try and get the
+ // appropriate timing info.
+ DWORD const attrs = GetFileAttributesW(path.c_str());
+ if (attrs != INVALID_FILE_ATTRIBUTES && (attrs & FILE_ATTRIBUTE_DIRECTORY)) {
+ return cmSystemTools::GetWindowsDirectoryRetry();
+ }
+ return cmSystemTools::GetWindowsFileRetry();
+}
+
} // end of anonymous namespace
cmSystemTools::WindowsFileRetry cmSystemTools::GetWindowsFileRetry()
@@ -912,7 +923,7 @@ bool cmSystemTools::RenameFile(const std::string& oldname,
fails then remove the read-only attribute from any existing destination.
Try multiple times since we may be racing against another process
creating/opening the destination file just before our MoveFileEx. */
- WindowsFileRetry retry = cmSystemTools::GetWindowsFileRetry();
+ WindowsFileRetry retry = GetWindowsRetry(oldname_wstr);
DWORD move_last_error = 0;
while (!cmMoveFile(oldname_wstr, newname_wstr) && --retry.Count) {
move_last_error = GetLastError();