From 49bd89fe31f9a5d064c9ae863798349838badc21 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 22 Jan 2004 10:30:01 -0500 Subject: 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. --- Source/cmake.cxx | 19 +++++++++++++++---- Source/kwsys/SystemTools.cxx | 7 +++---- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 8416fe2..50170c6 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -660,15 +660,26 @@ int cmake::CMakeCommand(std::vector& args) // Copy file if (args[1] == "copy" && args.size() == 4) { - cmSystemTools::cmCopyFile(args[2].c_str(), args[3].c_str()); - return cmSystemTools::GetErrorOccuredFlag(); + if(!cmSystemTools::cmCopyFile(args[2].c_str(), args[3].c_str())) + { + std::cerr << "Error copying file \"" << args[2].c_str() + << "\" to \"" << args[3].c_str() << "\".\n"; + return 1; + } + return 0; } // Copy file if different. if (args[1] == "copy_if_different" && args.size() == 4) { - cmSystemTools::CopyFileIfDifferent(args[2].c_str(), args[3].c_str()); - return cmSystemTools::GetErrorOccuredFlag(); + if(!cmSystemTools::CopyFileIfDifferent(args[2].c_str(), args[3].c_str())) + { + std::cerr << "Error copying file (if different) from \"" + << args[2].c_str() << "\" to \"" << args[3].c_str() + << "\".\n"; + return 1; + } + return 0; } // Echo string diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx index d525be3..825e27e 100644 --- a/Source/kwsys/SystemTools.cxx +++ b/Source/kwsys/SystemTools.cxx @@ -816,14 +816,13 @@ kwsys_stl::string SystemTools::ConvertToWindowsOutputPath(const char* path) } bool SystemTools::CopyFileIfDifferent(const char* source, - const char* destination) + const char* destination) { if(SystemTools::FilesDiffer(source, destination)) { - SystemTools::CopyFileAlways(source, destination); - return true; + return SystemTools::CopyFileAlways(source, destination); } - return false; + return true; } -- cgit v0.12