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.
This commit is contained in:
parent
0d92350bb6
commit
aba3d56c92
@ -955,6 +955,8 @@ void CMakeCommandUsage(const char* program)
|
|||||||
<< "Usage: " << program << " -E [command] [arguments ...]\n"
|
<< "Usage: " << program << " -E [command] [arguments ...]\n"
|
||||||
<< "Available commands: \n"
|
<< "Available commands: \n"
|
||||||
<< " chdir dir cmd [args]... - run command in a given directory\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 "
|
<< " copy file destination - copy file to destination (either file "
|
||||||
"or directory)\n"
|
"or directory)\n"
|
||||||
<< " copy_if_different in-file out-file - copy file if input has "
|
<< " 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;
|
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
|
// Compare files
|
||||||
if (args[1] == "compare_files" && args.size() == 4)
|
if (args[1] == "compare_files" && args.size() == 4)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user