summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2003-01-19 16:42:37 (GMT)
committerBrad King <brad.king@kitware.com>2003-01-19 16:42:37 (GMT)
commit6d54cfb030c337e3c29814cd530913d99635ff5b (patch)
tree8faef44f8f39f9cb058b2abdb9c9f8c883b55ce5 /Source
parentf18e47c40a318bbcbf603ef0978c2ff1b165248a (diff)
downloadCMake-6d54cfb030c337e3c29814cd530913d99635ff5b.zip
CMake-6d54cfb030c337e3c29814cd530913d99635ff5b.tar.gz
CMake-6d54cfb030c337e3c29814cd530913d99635ff5b.tar.bz2
ENH: Improved CopyFile error messages.
Diffstat (limited to 'Source')
-rw-r--r--Source/cmSystemTools.cxx52
1 files changed, 34 insertions, 18 deletions
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx
index e67708f..6b10ab2 100644
--- a/Source/cmSystemTools.cxx
+++ b/Source/cmSystemTools.cxx
@@ -1064,12 +1064,13 @@ void cmSystemTools::cmCopyFile(const char* source,
std::ifstream fin(source);
#endif
if(!fin)
- {
- std::string m = "CopyFile failed to open input file \"";
+ {
+ int e = errno;
+ std::string m = "CopyFile failed to open source file \"";
m += source;
m += "\"";
m += " System Error: ";
- m += strerror(errno);
+ m += strerror(e);
cmSystemTools::Error(m.c_str());
return;
}
@@ -1083,11 +1084,12 @@ void cmSystemTools::cmCopyFile(const char* source,
#endif
if(!fout)
{
- std::string m = "CopyFile failed to open output file \"";
+ int e = errno;
+ std::string m = "CopyFile failed to open destination file \"";
m += destination;
m += "\"";
m += " System Error: ";
- m += strerror(errno);
+ m += strerror(e);
cmSystemTools::Error(m.c_str());
return;
}
@@ -1114,23 +1116,37 @@ void cmSystemTools::cmCopyFile(const char* source,
fin.close();
fout.close();
- // More checks
-
+ // More checks.
struct stat statSource, statDestination;
- if (stat(source, &statSource) != 0 ||
- stat(destination, &statDestination) != 0)
+ statSource.st_size = 12345;
+ statDestination.st_size = 12345;
+ if(stat(source, &statSource) != 0)
{
- cmSystemTools::Error("CopyFile failed to copy files!");
+ int e = errno;
+ std::string m = "CopyFile failed to stat source file \"";
+ m += source;
+ m += "\"";
+ m += " System Error: ";
+ m += strerror(e);
+ cmSystemTools::Error(m.c_str());
}
- else
+ else if(stat(destination, &statDestination) != 0)
{
- if (statSource.st_size != statDestination.st_size)
- {
- cmOStringStream msg;
- msg << "CopyFile failed to copy files (sizes differ, source: "
- << statSource.st_size << " , dest: " << statDestination.st_size;
- cmSystemTools::Error(msg.str().c_str());
- }
+ int e = errno;
+ std::string m = "CopyFile failed to stat destination file \"";
+ m += source;
+ m += "\"";
+ m += " System Error: ";
+ m += strerror(e);
+ cmSystemTools::Error(m.c_str());
+ }
+ else if(statSource.st_size != statDestination.st_size)
+ {
+ cmOStringStream msg;
+ msg << "CopyFile failed to copy files: source \""
+ << source << "\", size " << statSource.st_size << ", destination \""
+ << destination << "\", size " << statDestination.st_size;
+ cmSystemTools::Error(msg.str().c_str());
}
}