From b1541f3ee5adc63507e3f6e1cfe1a5840d23e3db Mon Sep 17 00:00:00 2001 From: Bill Hoffman Date: Fri, 15 Apr 2005 10:46:19 -0400 Subject: BUG: work around for buggy Tigger OSX systems that read two copies of the same file in a directory --- Source/cmTryCompileCommand.cxx | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/Source/cmTryCompileCommand.cxx b/Source/cmTryCompileCommand.cxx index df06871..3991f21 100644 --- a/Source/cmTryCompileCommand.cxx +++ b/Source/cmTryCompileCommand.cxx @@ -282,25 +282,32 @@ void cmTryCompileCommand::CleanupFiles(const char* binDir) cmsys::Directory dir; dir.Load(binDir); size_t fileNum; + std::set deletedFiles; for (fileNum = 0; fileNum < dir.GetNumberOfFiles(); ++fileNum) { if (strcmp(dir.GetFile(static_cast(fileNum)),".") && strcmp(dir.GetFile(static_cast(fileNum)),"..")) { - std::string fullPath = binDir; - fullPath += "/"; - fullPath += dir.GetFile(static_cast(fileNum)); - if(cmSystemTools::FileIsDirectory(fullPath.c_str())) + + if(deletedFiles.find( dir.GetFile(static_cast(fileNum))) + == deletedFiles.end()) { - cmTryCompileCommand::CleanupFiles(fullPath.c_str()); - } - else - { - if(!cmSystemTools::RemoveFile(fullPath.c_str())) + deletedFiles.insert(dir.GetFile(static_cast(fileNum))); + std::string fullPath = binDir; + fullPath += "/"; + fullPath += dir.GetFile(static_cast(fileNum)); + if(cmSystemTools::FileIsDirectory(fullPath.c_str())) + { + cmTryCompileCommand::CleanupFiles(fullPath.c_str()); + } + else { - std::string m = "Remove failed on file: "; - m += fullPath; - cmSystemTools::ReportLastSystemError(m.c_str()); + if(!cmSystemTools::RemoveFile(fullPath.c_str())) + { + std::string m = "Remove failed on file: "; + m += fullPath; + cmSystemTools::ReportLastSystemError(m.c_str()); + } } } } -- cgit v0.12