From 62b612fbf841fd8d1d4e293ad84d933133543860 Mon Sep 17 00:00:00 2001 From: Bill Hoffman Date: Wed, 5 Feb 2003 22:26:55 -0500 Subject: [PATCH] add better testing for unlink --- Source/cmSystemTools.cxx | 10 +++++++++- Source/cmSystemTools.h | 4 ++++ Source/cmTryCompileCommand.cxx | 7 ++++++- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 95f4d59b8..b395c98f0 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -15,7 +15,6 @@ =========================================================================*/ #include "cmSystemTools.h" -#include "errno.h" #include #include #include "cmRegularExpression.h" @@ -1166,6 +1165,15 @@ long int cmSystemTools::ModifiedTime(const char* filename) } +void cmSystemTools::ReportLastSystemError(const char* msg) +{ + int e = errno; + std::string m = msg; + m += ": System Error: "; + m += strerror(e); + cmSystemTools::Error(m.c_str()); +} + bool cmSystemTools::RemoveFile(const char* source) { diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h index c977cedb1..3cd332112 100644 --- a/Source/cmSystemTools.h +++ b/Source/cmSystemTools.h @@ -353,6 +353,10 @@ public: */ static void SetRunCommandHideConsole(bool v){s_RunCommandHideConsole = v;} static bool GetRunCommandHideConsole(){ return s_RunCommandHideConsole;} + /** Call cmSystemTools::Error with the message m, plus the + * result of strerror(errno) + */ + static void ReportLastSystemError(const char* m); /** When building DEBUG with MSVC, this enables a hook that prevents * error dialogs from popping up if the program is being run from diff --git a/Source/cmTryCompileCommand.cxx b/Source/cmTryCompileCommand.cxx index 9a0a6ac1d..e2848da74 100644 --- a/Source/cmTryCompileCommand.cxx +++ b/Source/cmTryCompileCommand.cxx @@ -280,7 +280,12 @@ void cmTryCompileCommand::CleanupFiles(const char* binDir) } else { - cmSystemTools::RemoveFile(fullPath.c_str()); + if(!cmSystemTools::RemoveFile(fullPath.c_str())) + { + std::string m = "Remove failed on file: "; + m += fullPath; + cmSystemTools::ReportLastSystemError(m.c_str()); + } } } }