mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-18 17:31:57 +08:00
try_compile: Improve error message when a file cannot be removed
This commit is contained in:
@@ -1015,17 +1015,21 @@ void cmCoreTryCompile::CleanupFiles(std::string const& binDir)
|
||||
// cannot delete them immediately. Try a few times.
|
||||
cmSystemTools::WindowsFileRetry retry =
|
||||
cmSystemTools::GetWindowsFileRetry();
|
||||
while (!cmSystemTools::RemoveFile(fullPath) && --retry.Count &&
|
||||
cmSystemTools::FileExists(fullPath)) {
|
||||
cmsys::Status status;
|
||||
while (!((status = cmSystemTools::RemoveFile(fullPath))) &&
|
||||
--retry.Count && cmSystemTools::FileExists(fullPath)) {
|
||||
cmSystemTools::Delay(retry.Delay);
|
||||
}
|
||||
if (retry.Count == 0)
|
||||
#else
|
||||
if (!cmSystemTools::RemoveFile(fullPath))
|
||||
cmsys::Status status = cmSystemTools::RemoveFile(fullPath);
|
||||
if (!status)
|
||||
#endif
|
||||
{
|
||||
std::string m = "Remove failed on file: " + fullPath;
|
||||
cmSystemTools::ReportLastSystemError(m.c_str());
|
||||
this->Makefile->IssueMessage(
|
||||
MessageType::FATAL_ERROR,
|
||||
cmStrCat("The file:\n ", fullPath,
|
||||
"\ncould not be removed:\n ", status.GetString()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user