BUG: CopyFileIfDifferent should return success if the files did not differ or if the copy succeeded. It should return failure only if the files were different and the copy failed.

This commit is contained in:
Brad King 2004-01-22 10:30:01 -05:00
parent f9a3f74d87
commit 49bd89fe31
2 changed files with 18 additions and 8 deletions

View File

@ -660,15 +660,26 @@ int cmake::CMakeCommand(std::vector<std::string>& args)
// Copy file // Copy file
if (args[1] == "copy" && args.size() == 4) if (args[1] == "copy" && args.size() == 4)
{ {
cmSystemTools::cmCopyFile(args[2].c_str(), args[3].c_str()); if(!cmSystemTools::cmCopyFile(args[2].c_str(), args[3].c_str()))
return cmSystemTools::GetErrorOccuredFlag(); {
std::cerr << "Error copying file \"" << args[2].c_str()
<< "\" to \"" << args[3].c_str() << "\".\n";
return 1;
}
return 0;
} }
// Copy file if different. // Copy file if different.
if (args[1] == "copy_if_different" && args.size() == 4) if (args[1] == "copy_if_different" && args.size() == 4)
{ {
cmSystemTools::CopyFileIfDifferent(args[2].c_str(), args[3].c_str()); if(!cmSystemTools::CopyFileIfDifferent(args[2].c_str(), args[3].c_str()))
return cmSystemTools::GetErrorOccuredFlag(); {
std::cerr << "Error copying file (if different) from \""
<< args[2].c_str() << "\" to \"" << args[3].c_str()
<< "\".\n";
return 1;
}
return 0;
} }
// Echo string // Echo string

View File

@ -816,14 +816,13 @@ kwsys_stl::string SystemTools::ConvertToWindowsOutputPath(const char* path)
} }
bool SystemTools::CopyFileIfDifferent(const char* source, bool SystemTools::CopyFileIfDifferent(const char* source,
const char* destination) const char* destination)
{ {
if(SystemTools::FilesDiffer(source, destination)) if(SystemTools::FilesDiffer(source, destination))
{ {
SystemTools::CopyFileAlways(source, destination); return SystemTools::CopyFileAlways(source, destination);
return true;
} }
return false; return true;
} }