diff options
author | Brad King <brad.king@kitware.com> | 2020-08-27 19:43:51 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2020-08-31 17:03:11 (GMT) |
commit | 97fc44f70e2c97799d1b802289f220efd055be20 (patch) | |
tree | 99d6fb7fcddd0ed30da80a7b10a425f0db5c34ac /Source/cmSystemTools.cxx | |
parent | 35039286eb6e1fe6161524481bebda9bcd30bb84 (diff) | |
download | CMake-97fc44f70e2c97799d1b802289f220efd055be20.zip CMake-97fc44f70e2c97799d1b802289f220efd055be20.tar.gz CMake-97fc44f70e2c97799d1b802289f220efd055be20.tar.bz2 |
cmSystemTools: Factor out MoveFileExW call in RenameFile
Diffstat (limited to 'Source/cmSystemTools.cxx')
-rw-r--r-- | Source/cmSystemTools.cxx | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 8112fee..a9785db 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -881,6 +881,16 @@ void cmSystemTools::InitializeLibUV() #endif } +#ifdef _WIN32 +namespace { +bool cmMoveFile(std::wstring const& oldname, std::wstring const& newname) +{ + return MoveFileExW(oldname.c_str(), newname.c_str(), + MOVEFILE_REPLACE_EXISTING); +} +} +#endif + bool cmSystemTools::RenameFile(const std::string& oldname, const std::string& newname) { @@ -893,11 +903,9 @@ bool cmSystemTools::RenameFile(const std::string& oldname, Try multiple times since we may be racing against another process creating/opening the destination file just before our MoveFileEx. */ WindowsFileRetry retry = cmSystemTools::GetWindowsFileRetry(); - while ( - !MoveFileExW(SystemTools::ConvertToWindowsExtendedPath(oldname).c_str(), - SystemTools::ConvertToWindowsExtendedPath(newname).c_str(), - MOVEFILE_REPLACE_EXISTING) && - --retry.Count) { + while (!cmMoveFile(SystemTools::ConvertToWindowsExtendedPath(oldname), + SystemTools::ConvertToWindowsExtendedPath(newname)) && + --retry.Count) { DWORD last_error = GetLastError(); // Try again only if failure was due to access/sharing permissions. if (last_error != ERROR_ACCESS_DENIED && |