Merge topic 'fix-atomic-rename-Windows-sharing-violation'

24bd7ae1 cmSystemTools::RenameFile: Retry on Windows ERROR_SHARING_VIOLATION
This commit is contained in:
Brad King 2014-05-14 13:58:33 -04:00 committed by CMake Topic Stage
commit 775458dede
1 changed files with 4 additions and 2 deletions

View File

@ -886,8 +886,10 @@ bool cmSystemTools::RenameFile(const char* oldname, const char* newname)
cmsys::Encoding::ToWide(newname).c_str(),
MOVEFILE_REPLACE_EXISTING) && --retry.Count)
{
// Try again only if failure was due to access permissions.
if(GetLastError() != ERROR_ACCESS_DENIED)
DWORD last_error = GetLastError();
// Try again only if failure was due to access/sharing permissions.
if(last_error != ERROR_ACCESS_DENIED &&
last_error != ERROR_SHARING_VIOLATION)
{
return false;
}