ENH: Improved CopyFile error messages.
This commit is contained in:
parent
f18e47c40a
commit
6d54cfb030
|
@ -1065,11 +1065,12 @@ void cmSystemTools::cmCopyFile(const char* source,
|
||||||
#endif
|
#endif
|
||||||
if(!fin)
|
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 += source;
|
||||||
m += "\"";
|
m += "\"";
|
||||||
m += " System Error: ";
|
m += " System Error: ";
|
||||||
m += strerror(errno);
|
m += strerror(e);
|
||||||
cmSystemTools::Error(m.c_str());
|
cmSystemTools::Error(m.c_str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1083,11 +1084,12 @@ void cmSystemTools::cmCopyFile(const char* source,
|
||||||
#endif
|
#endif
|
||||||
if(!fout)
|
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 += destination;
|
||||||
m += "\"";
|
m += "\"";
|
||||||
m += " System Error: ";
|
m += " System Error: ";
|
||||||
m += strerror(errno);
|
m += strerror(e);
|
||||||
cmSystemTools::Error(m.c_str());
|
cmSystemTools::Error(m.c_str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1114,24 +1116,38 @@ void cmSystemTools::cmCopyFile(const char* source,
|
||||||
fin.close();
|
fin.close();
|
||||||
fout.close();
|
fout.close();
|
||||||
|
|
||||||
// More checks
|
// More checks.
|
||||||
|
|
||||||
struct stat statSource, statDestination;
|
struct stat statSource, statDestination;
|
||||||
if (stat(source, &statSource) != 0 ||
|
statSource.st_size = 12345;
|
||||||
stat(destination, &statDestination) != 0)
|
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)
|
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;
|
cmOStringStream msg;
|
||||||
msg << "CopyFile failed to copy files (sizes differ, source: "
|
msg << "CopyFile failed to copy files: source \""
|
||||||
<< statSource.st_size << " , dest: " << statDestination.st_size;
|
<< source << "\", size " << statSource.st_size << ", destination \""
|
||||||
|
<< destination << "\", size " << statDestination.st_size;
|
||||||
cmSystemTools::Error(msg.str().c_str());
|
cmSystemTools::Error(msg.str().c_str());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// return true if the file exists
|
// return true if the file exists
|
||||||
|
|
Loading…
Reference in New Issue