#include "shell.hpp" void shell::c_cp (std::string args) { // split args into source and target std::string src = args; std::string tgt = args; size_t idx = args.find (" "); if ( idx != 0 && idx != std::string::npos ) { src.erase (idx); tgt.erase (0, idx + 1); } else { carp ("format: cp "); } // sanity checks if ( ! cwd_.exists (src) ) { carp ("No such file: " + src); return; } if ( cwd_.is_dir (src) ) { carp ("cannot copy directory: " + src); return; } if ( cwd_.exists (tgt) && ! cwd_.is_dir (tgt) ) { carp ("already exists: " + tgt); return; } // copy! cwd_.copy (saga::url (src), saga::url (tgt)); return; }