diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 0d0102ede8..4c44c832bc 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -1645,20 +1645,6 @@ cmSystemTools::CopyResult cmSystemTools::CopySingleFile( return CopyResult::Success; } -bool cmSystemTools::CopyFileIfNewer(std::string const& source, - std::string const& destination) -{ - return cmsys::SystemTools::CopyFileIfNewer(source, destination).IsSuccess(); -} - -bool cmSystemTools::CopyADirectory(std::string const& source, - std::string const& destination, - CopyWhen when) -{ - return cmsys::SystemTools::CopyADirectory(source, destination, when) - .IsSuccess(); -} - bool cmSystemTools::RenameFile(std::string const& oldname, std::string const& newname) { diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h index 9330482937..946dea93c2 100644 --- a/Source/cmSystemTools.h +++ b/Source/cmSystemTools.h @@ -205,15 +205,6 @@ public: CopyInputRecent inputRecent, std::string* err = nullptr); - /** Copy a file if it is newer than the destination. */ - static bool CopyFileIfNewer(std::string const& source, - std::string const& destination); - - /** Copy directory contents with specified copy behavior. */ - static bool CopyADirectory(std::string const& source, - std::string const& destination, - CopyWhen when = CopyWhen::Always); - enum class Replace { Yes, diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx index 66abbc1bf2..019b366942 100644 --- a/Source/cmcmd.cxx +++ b/Source/cmcmd.cxx @@ -749,9 +749,11 @@ int cmcmd::ExecuteCMakeCommand(std::vector const& args, // If error occurs we want to continue copying next files. bool return_value = false; for (auto const& file : files) { - if (!cmsys::SystemTools::CopyFileAlways(file, *targetArg)) { + cmsys::SystemTools::CopyStatus const status = + cmSystemTools::CopyFileAlways(file, *targetArg); + if (!status) { std::cerr << "Error copying file \"" << file << "\" to \"" - << *targetArg << "\".\n"; + << *targetArg << "\": " << status.GetString() << '\n'; return_value = true; } } @@ -771,9 +773,12 @@ int cmcmd::ExecuteCMakeCommand(std::vector const& args, // If error occurs we want to continue copying next files. bool return_value = false; for (auto const& arg : cmMakeRange(args).advance(2).retreat(1)) { - if (!cmSystemTools::CopyFileIfDifferent(arg, args.back())) { + cmsys::SystemTools::CopyStatus const status = + cmSystemTools::CopyFileIfDifferent(arg, args.back()); + if (!status) { std::cerr << "Error copying file (if different) from \"" << arg - << "\" to \"" << args.back() << "\".\n"; + << "\" to \"" << args.back() + << "\": " << status.GetString() << '\n'; return_value = true; } } @@ -793,9 +798,12 @@ int cmcmd::ExecuteCMakeCommand(std::vector const& args, // If error occurs we want to continue copying next files. bool return_value = false; for (auto const& arg : cmMakeRange(args).advance(2).retreat(1)) { - if (!cmSystemTools::CopyFileIfNewer(arg, args.back())) { + cmsys::SystemTools::CopyStatus const status = + cmSystemTools::CopyFileIfNewer(arg, args.back()); + if (!status) { std::cerr << "Error copying file (if newer) from \"" << arg - << "\" to \"" << args.back() << "\".\n"; + << "\" to \"" << args.back() + << "\": " << status.GetString() << '\n'; return_value = true; } } @@ -818,9 +826,11 @@ int cmcmd::ExecuteCMakeCommand(std::vector const& args, } for (auto const& arg : cmMakeRange(args).advance(2).retreat(1)) { - if (!cmSystemTools::CopyADirectory(arg, args.back(), when)) { + cmsys::Status const status = + cmSystemTools::CopyADirectory(arg, args.back(), when); + if (!status) { std::cerr << "Error copying directory from \"" << arg << "\" to \"" - << args.back() << "\".\n"; + << args.back() << "\": " << status.GetString() << '\n'; return_value = true; } } @@ -1023,8 +1033,10 @@ int cmcmd::ExecuteCMakeCommand(std::vector const& args, // If an error occurs, we want to continue making directories. bool return_value = false; for (auto const& arg : cmMakeRange(args).advance(2)) { - if (!cmSystemTools::MakeDirectory(arg)) { - std::cerr << "Error creating directory \"" << arg << "\".\n"; + cmsys::Status const status = cmSystemTools::MakeDirectory(arg); + if (!status) { + std::cerr << "Error creating directory \"" << arg + << "\": " << status.GetString() << '\n'; return_value = true; } } diff --git a/Tests/RunCMake/CommandLine/E_copy_directory-three-source-files-target-is-file-stderr.txt b/Tests/RunCMake/CommandLine/E_copy_directory-three-source-files-target-is-file-stderr.txt index 6e1a614115..51209833d4 100644 --- a/Tests/RunCMake/CommandLine/E_copy_directory-three-source-files-target-is-file-stderr.txt +++ b/Tests/RunCMake/CommandLine/E_copy_directory-three-source-files-target-is-file-stderr.txt @@ -1,3 +1,3 @@ -^Error copying directory from .* to .*file_for_test\.txt\".* -Error copying directory from .* to .*file_for_test\.txt\".* -Error copying directory from .* to .*file_for_test\.txt\"\.$ +^Error copying directory from "[^"]+" to "[^"]+file_for_test\.txt": File exists +Error copying directory from "[^"]+" to "[^"]+file_for_test\.txt": File exists +Error copying directory from "[^"]+" to "[^"]+file_for_test\.txt": File exists$ diff --git a/Tests/RunCMake/CommandLine/E_copy_directory_if_newer-nonexistent-source-stderr.txt b/Tests/RunCMake/CommandLine/E_copy_directory_if_newer-nonexistent-source-stderr.txt index 248ebb4040..8533666c77 100644 --- a/Tests/RunCMake/CommandLine/E_copy_directory_if_newer-nonexistent-source-stderr.txt +++ b/Tests/RunCMake/CommandLine/E_copy_directory_if_newer-nonexistent-source-stderr.txt @@ -1 +1 @@ -^Error copying directory from ".+" to ".+"\.$ +^Error copying directory from "[^"]+" to "[^"]+": (No such file or directory|The system cannot find the path specified\.)$ diff --git a/Tests/RunCMake/CommandLine/E_copy_if_different-nonexistent-source-stderr.txt b/Tests/RunCMake/CommandLine/E_copy_if_different-nonexistent-source-stderr.txt index ce1099b329..f54f4ae3ca 100644 --- a/Tests/RunCMake/CommandLine/E_copy_if_different-nonexistent-source-stderr.txt +++ b/Tests/RunCMake/CommandLine/E_copy_if_different-nonexistent-source-stderr.txt @@ -1 +1 @@ -^Error copying file \(if different\) from ".+" to ".+"\.$ +^Error copying file \(if different\) from "[^"]+" to "[^"]+": No such file or directory$ diff --git a/Tests/RunCMake/CommandLine/E_copy_if_newer-nonexistent-source-stderr.txt b/Tests/RunCMake/CommandLine/E_copy_if_newer-nonexistent-source-stderr.txt index 52e51bce07..cbe1f4643c 100644 --- a/Tests/RunCMake/CommandLine/E_copy_if_newer-nonexistent-source-stderr.txt +++ b/Tests/RunCMake/CommandLine/E_copy_if_newer-nonexistent-source-stderr.txt @@ -1 +1 @@ -^Error copying file \(if newer\) from ".+" to ".+"\.$ +^Error copying file \(if newer\) from "[^"]+" to "[^"]+": No such file or directory$ diff --git a/Tests/RunCMake/CommandLine/E_make_directory-two-directories-and-file-stderr.txt b/Tests/RunCMake/CommandLine/E_make_directory-two-directories-and-file-stderr.txt index 17c68ed21a..992a4b0f0b 100644 --- a/Tests/RunCMake/CommandLine/E_make_directory-two-directories-and-file-stderr.txt +++ b/Tests/RunCMake/CommandLine/E_make_directory-two-directories-and-file-stderr.txt @@ -1 +1 @@ -^Error creating directory .*file_for_test\.txt\"\.$ +^Error creating directory "[^"]+file_for_test\.txt": File exists$