summaryrefslogtreecommitdiffstats
path: root/Source/cmCoreTryCompile.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2010-12-16 19:00:28 (GMT)
committerCMake Topic Stage <kwrobot@kitware.com>2010-12-16 19:00:28 (GMT)
commit72ebd4ee12fc99b5302c18619f120bd9c285b474 (patch)
tree87b8ef134181ba6f861573274dc6cfcde63c2dd9 /Source/cmCoreTryCompile.cxx
parent6b61c04330fa693c1e246c94e230ff8641dee00e (diff)
parent097294e6670ccfb3e2ca8101dc6468e917042600 (diff)
downloadCMake-72ebd4ee12fc99b5302c18619f120bd9c285b474.zip
CMake-72ebd4ee12fc99b5302c18619f120bd9c285b474.tar.gz
CMake-72ebd4ee12fc99b5302c18619f120bd9c285b474.tar.bz2
Merge topic 'try_compile-RemoveFile'
097294e Fix try_compile RemoveFile anti-virus loop (#11503)
Diffstat (limited to 'Source/cmCoreTryCompile.cxx')
-rw-r--r--Source/cmCoreTryCompile.cxx32
1 files changed, 11 insertions, 21 deletions
diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx
index a1c707d..0fe64ad 100644
--- a/Source/cmCoreTryCompile.cxx
+++ b/Source/cmCoreTryCompile.cxx
@@ -397,28 +397,18 @@ void cmCoreTryCompile::CleanupFiles(const char* binDir)
}
else
{
- if(!cmSystemTools::RemoveFile(fullPath.c_str()))
+ // Sometimes anti-virus software hangs on to new files so we
+ // cannot delete them immediately. Try a few times.
+ int tries = 5;
+ while(!cmSystemTools::RemoveFile(fullPath.c_str()) &&
+ --tries && cmSystemTools::FileExists(fullPath.c_str()))
{
- bool removed = false;
- int numAttempts = 0;
- // sometimes anti-virus software hangs on to
- // new files and we can not delete them, so try
- // 5 times with .5 second delay between tries.
- while(!removed && numAttempts < 5)
- {
- cmSystemTools::Delay(500);
- if(cmSystemTools::RemoveFile(fullPath.c_str()))
- {
- removed = true;
- }
- numAttempts++;
- }
- if(!removed)
- {
- std::string m = "Remove failed on file: ";
- m += fullPath;
- cmSystemTools::ReportLastSystemError(m.c_str());
- }
+ cmSystemTools::Delay(500);
+ }
+ if(tries == 0)
+ {
+ std::string m = "Remove failed on file: " + fullPath;
+ cmSystemTools::ReportLastSystemError(m.c_str());
}
}
}