mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-19 02:17:27 +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.
|
// cannot delete them immediately. Try a few times.
|
||||||
cmSystemTools::WindowsFileRetry retry =
|
cmSystemTools::WindowsFileRetry retry =
|
||||||
cmSystemTools::GetWindowsFileRetry();
|
cmSystemTools::GetWindowsFileRetry();
|
||||||
while (!cmSystemTools::RemoveFile(fullPath) && --retry.Count &&
|
cmsys::Status status;
|
||||||
cmSystemTools::FileExists(fullPath)) {
|
while (!((status = cmSystemTools::RemoveFile(fullPath))) &&
|
||||||
|
--retry.Count && cmSystemTools::FileExists(fullPath)) {
|
||||||
cmSystemTools::Delay(retry.Delay);
|
cmSystemTools::Delay(retry.Delay);
|
||||||
}
|
}
|
||||||
if (retry.Count == 0)
|
if (retry.Count == 0)
|
||||||
#else
|
#else
|
||||||
if (!cmSystemTools::RemoveFile(fullPath))
|
cmsys::Status status = cmSystemTools::RemoveFile(fullPath);
|
||||||
|
if (!status)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
std::string m = "Remove failed on file: " + fullPath;
|
this->Makefile->IssueMessage(
|
||||||
cmSystemTools::ReportLastSystemError(m.c_str());
|
MessageType::FATAL_ERROR,
|
||||||
|
cmStrCat("The file:\n ", fullPath,
|
||||||
|
"\ncould not be removed:\n ", status.GetString()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user