summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2009-04-15 13:58:33 (GMT)
committerBrad King <brad.king@kitware.com>2009-04-15 13:58:33 (GMT)
commitaba3d56c929256771049ec64a53d2e7067e342b8 (patch)
tree767b452bec2e82c5c286165d88bac59493bb56f3 /Source
parent0d92350bb67de4632220e63d8f02c062596896d1 (diff)
downloadCMake-aba3d56c929256771049ec64a53d2e7067e342b8.zip
CMake-aba3d56c929256771049ec64a53d2e7067e342b8.tar.gz
CMake-aba3d56c929256771049ec64a53d2e7067e342b8.tar.bz2
ENH: Create command line api "cmake -E rename"
This extends the "-E" command line mode with a "rename old new" signature. The new command atomically renames a file or directory within a single disk volume.
Diffstat (limited to 'Source')
-rw-r--r--Source/cmake.cxx16
1 files changed, 16 insertions, 0 deletions
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index df528e2..83d779b 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -955,6 +955,8 @@ void CMakeCommandUsage(const char* program)
<< "Usage: " << program << " -E [command] [arguments ...]\n"
<< "Available commands: \n"
<< " chdir dir cmd [args]... - run command in a given directory\n"
+ << " rename oldname newname - rename a file or directory "
+ "(on one volume)\n"
<< " copy file destination - copy file to destination (either file "
"or directory)\n"
<< " copy_if_different in-file out-file - copy file if input has "
@@ -1033,6 +1035,20 @@ int cmake::ExecuteCMakeCommand(std::vector<std::string>& args)
return 0;
}
+ // Rename a file or directory
+ if (args[1] == "rename" && args.size() == 4)
+ {
+ if(!cmSystemTools::RenameFile(args[2].c_str(), args[3].c_str()))
+ {
+ std::string e = cmSystemTools::GetLastSystemError();
+ std::cerr << "Error renaming from \""
+ << args[2].c_str() << "\" to \"" << args[3].c_str()
+ << "\": " << e << "\n";
+ return 1;
+ }
+ return 0;
+ }
+
// Compare files
if (args[1] == "compare_files" && args.size() == 4)
{
tle='2005-06-06 10:28:06 (GMT)'>2005-06-061-0/+1 * fixes pybsddb SF bug id 1215432. DB.associate() would crash when aGregory P. Smith2005-06-061-5/+3 * Correct URL to the official UnicodeData 3.2.0 resource. (ReportedHye-Shik Chang2005-06-041-1/+1 * pybsddb 4.3.2:Gregory P. Smith2005-06-041-24/+64 * Bug #1194181: bz2.BZ2File didn't handle mode 'U' correctly.Georg Brandl2005-06-031-0/+4 * pybsddb 4.3.1, adds support for DB.set_bt_compare database btree comparisonGregory P. Smith2005-06-03