diff options
author | John Freeman <jfreeman08@gmail.com> | 2019-05-31 21:35:41 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2019-06-03 18:20:00 (GMT) |
commit | 07a80c70020e0e533db8d75d7fe7c4270cc25afb (patch) | |
tree | 71e52d98611f1f1042f976b7cd505f6dd1cf95c2 /Source/cmcmd.cxx | |
parent | 013bee698e8470169d99e90aa86d5d85693c6b12 (diff) | |
download | CMake-07a80c70020e0e533db8d75d7fe7c4270cc25afb.zip CMake-07a80c70020e0e533db8d75d7fe7c4270cc25afb.tar.gz CMake-07a80c70020e0e533db8d75d7fe7c4270cc25afb.tar.bz2 |
cmake: Teach -E remove_directory to remove multiple directories
The `make_directory` command can make multiple directories in a single
invocation. Make `remove_directory` mirror that behavior.
Diffstat (limited to 'Source/cmcmd.cxx')
-rw-r--r-- | Source/cmcmd.cxx | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx index f4ef45c..a983d30 100644 --- a/Source/cmcmd.cxx +++ b/Source/cmcmd.cxx @@ -103,7 +103,7 @@ void CMakeCommandUsage(const char* program) << " sha512sum <file>... - create SHA512 checksum of files\n" << " remove [-f] <file>... - remove the file(s), use -f to force " "it\n" - << " remove_directory dir - remove a directory and its contents\n" + << " remove_directory <dir>... - remove directories and their contents\n" << " rename oldname newname - rename a file or directory " "(on one volume)\n" << " server - start cmake in server mode\n" @@ -661,7 +661,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string> const& args) #endif if (args[1] == "make_directory" && args.size() > 2) { - // If error occurs we want to continue copying next files. + // 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)) { @@ -672,13 +672,17 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string> const& args) return return_value; } - if (args[1] == "remove_directory" && args.size() == 3) { - if (cmSystemTools::FileIsDirectory(args[2]) && - !cmSystemTools::RemoveADirectory(args[2])) { - std::cerr << "Error removing directory \"" << args[2] << "\".\n"; - return 1; + if (args[1] == "remove_directory" && args.size() > 2) { + // If an error occurs, we want to continue removing directories. + bool return_value = false; + for (auto const& arg : cmMakeRange(args).advance(2)) { + if (cmSystemTools::FileIsDirectory(arg) && + !cmSystemTools::RemoveADirectory(arg)) { + std::cerr << "Error removing directory \"" << arg << "\".\n"; + return_value = true; + } } - return 0; + return return_value; } // Remove file |