bool MakeDynLink::Action() { if (GetParams()->size() < 2) { return false; } else { Cmd* cmd = Cmd::Instance(); Fs::Path path1 = GetParams()->at(0); Fs::Path path2 = GetParams()->at(1); Fs::Object* obj = cmd->GetWorkPath(&path1); if (obj) { if (!path1.GetFile().empty()) { for (size_t i = 0; i < obj->GetChilds().size(); i++) { if (cmd->GetFs()->IsFile(obj->GetChilds()[i]) && (obj->GetChilds()[i]->GetName() == path1.GetFile())) { cmd->GetFs()->MakeDynLink(obj->GetChilds()[i], cmd->GetWorkPath(&path2)); break; } } } else { cmd->GetFs()->MakeDynLink(obj, cmd->GetWorkPath(&path2)); } } } return true; }
bool DelTree::Action() { if (!GetParams()->empty()) { Cmd* cmd = Cmd::Instance(); cmd->GetFs()->DelTree(cmd->GetWorkPath(&GetParams()->front())); } return true; }
bool RemoveDir::Action() { if (!GetParams()->empty()) { Cmd* cmd = Cmd::Instance(); cmd->GetFs()->RemoveDir(cmd->GetWorkPath(&GetParams()->front())); } return true; }
bool MakeFile::Action() { if (!GetParams()->empty()) { Cmd* cmd = Cmd::Instance(); cmd->GetFs()->MakeFile(cmd->GetWorkPath(&GetParams()->front()), &GetParams()->front()); } return true; }
bool MakeDir::Action() { if (!GetParams()->empty()) { Cmd* cmd = Cmd::Instance(); Fs::Path path = GetParams()->at(0); path.SetFile(path.GetPath()->back()); path.GetPath()->pop_back(); cmd->GetFs()->MakeDir(cmd->GetWorkPath(&path), &path); } return true; };
bool ChangeDir::Action() { Cmd* cmd = Cmd::Instance(); if (!GetParams()->empty()) { Fs::Path path = GetParams()->front(); Fs::Object* obj = cmd->GetCurrentPath(); obj = cmd->GetWorkPath(&path); if (obj) cmd->SetCurrentPath(obj); } return true; }
bool Del::Action() { if (!GetParams()->empty()) { Cmd* cmd = Cmd::Instance(); Fs::Object* obj = cmd->GetWorkPath(&GetParams()->front()); if (!GetParams()->front().GetFile().empty()) { for (size_t i = 0; i < obj->GetChilds().size(); i++) { if (obj->GetChilds()[i]->GetName() == GetParams()->front().GetFile()) { cmd->GetFs()->Del(obj->GetChilds()[i]); break; } } } } return true; }