本文整理汇总了C++中FileSystem::copy方法的典型用法代码示例。如果您正苦于以下问题:C++ FileSystem::copy方法的具体用法?C++ FileSystem::copy怎么用?C++ FileSystem::copy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileSystem
的用法示例。
在下文中一共展示了FileSystem::copy方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: execute
bool CommandCP::execute(FileSystem &fs, UDF& ) {
int fd = open(arguments[1].c_str(), O_WRONLY | O_CREAT | O_TRUNC, 0644);
FileEntry *node = fs.getCurrentNode();
if (fd == -1) {
std::cerr << "Error: unable to open file" << std::endl;
return false;
}
if (!fs.copy(arguments[0], fd)) {
return false;
}
fs.setCurrentNode(node);
std::cout << "Command CP executed." << std::endl;
return true;
}
示例2: main
int main (const int argc, const char *argv[]){
try {
if (argc < 4) {
std::cout << "Usage: copy root source destination" << std::endl;
} else {
FileSystem fs = FileSystem(argv[1]);
FileEntry source_d = fs.findEntry(argv[2], false);
FileEntry destination_d = fs.findEntry(argv[3], true, source_d.dir);
fs.copy(source_d, destination_d);
}
return 0;
} catch (const char *message) {
std::cerr << message << std::endl;
return 1;
} catch (const string msg) {
std::cerr << msg << std::endl;
return 1;
}
}
示例3: main
int main(void) {
//_CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
FileSystem fs;
string userCommand, commandArr[MAXCOMMANDS];
string user = "[email protected]"; // Change this if you want another user to be displayed
string currentDir = "/"; // current directory, used for output
bool bRun = true;
fs.format();
//HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
do {
currentDir = fs.GetCWD();
string data = "";
//SetConsoleTextAttribute(hConsole, 10);
cout << user << " ";
//SetConsoleTextAttribute(hConsole, 14);
cout << currentDir << endl;
//SetConsoleTextAttribute(hConsole, 15);
cout << "$ ";
getline(cin, userCommand);
for (unsigned i = 0; i < MAXCOMMANDS; ++i)
commandArr[i] = "";
int nrOfCommands = parseCommandString(userCommand, commandArr);
if (nrOfCommands > 0) {
int cIndex = findCommand(commandArr[0]);
switch(cIndex) {
case 0: // quit
bRun = false;
cout << "Exiting\n";
break;
case 1: // format
fs.format();
break;
case 2: // ls
if (commandArr[1] == "")
fs.ls();
else
fs.ls(commandArr[1]);
break;
case 3: // create
printf("Please Insert Data:\n");
getline( cin, data );
fs.create(commandArr[1],data);
break;
case 4: // cat
fs.cat(commandArr[1]);
break;
case 5: // createImage
fs.createImage( commandArr[1] );
break;
case 6: // restoreImage
fs.restoreImage( commandArr[1] );
break;
case 7: // rm
fs.rm(commandArr[1]);
break;
case 8: // copy
fs.copy( commandArr[1], commandArr[2] );
break;
case 9: // append
fs.append( commandArr[1], commandArr[2] );
break;
case 10: // rename
fs.rename( commandArr[1], commandArr[2] );
break;
case 11: // mkdir
fs.mkdir(commandArr[1]);
break;
case 12: // cd
fs.cd(commandArr[1]);
break;
case 13: // pwd
cout << fs.GetCWD() << endl;
break;
case 14: // help
cout << help() << endl;
break;
case 15: // rmdir
fs.rmdir(commandArr[1]);
break;
case 16: // chmod
fs.chmod( atoi( commandArr[1].c_str() ), commandArr[2] );
break;
//.........这里部分代码省略.........