#include #include #include #include #include #include "os.h" using namespace std; //function prototypes void run_command(OS*,vector*,string); void test_mlist(int,char**); void test_os(int,char**); void usage() { cerr << "usage: ./filesys "<< endl; cerr << "Examples:" << endl; cerr << "./filesys test_mlist <0-6>" << endl; cerr << "./filesys test_os <0-2>"< cmd; cout << "\e[1m\e[38;5;54mCS103L_PA6_shell:\e[0m\e[1m"; terminal.present_working_dir(); cout<<"$\e[0m "; getline(cin,input); stringstream ss(input); while(ss>>token){ cmd.push_back(token); } if(cmd.size() > 0){ string command = cmd.at(0); if(command == "exit" || command == "quit"){ cout<<"Good bye!!"< *cmd,string command){ if(command == "cd"){ if(cmd->size() < 2){ terminal->cd_dir("~"); }else{ terminal->cd_dir(cmd->at(1)); } }else if(command == "ls") { if(cmd->size() < 2){ //default option terminal->ls("-d"); }else{ terminal->ls(cmd->at(1)); } cout<present_working_dir(); cout<size()<2){ cout<<"usage: write [filename]"<file(cmd->at(1),false); } }else if(command == "read") { if(cmd->size()<2){ cout<<"usage: read [filename]"<file(cmd->at(1),true); } }else if(command == "rm") { if(cmd->size()<2){ cout<<"usage: rm [file or directory name]"<del(cmd->at(1)); } } else if(command == "mkfile") { if(cmd->size()<2){ cout<<"usage: mkfile [filename]"<create_item(cmd->at(1),false); } }else if(command == "mkdir") { if(cmd->size()<2){ cout<<"usage: mkdir [directory]"<create_item(cmd->at(1),true); } } else if(command == "help") { cout<<"*---------------------------"<nodeData->name<nodeData->name<nodeData->name<nodeData->name< ";list.printTtB(" ");cout<<"<-B"< c d(4) l <-B cout<<"B-> ";list.printBtT(" ");cout<<"<-T"< l d(4) c <-B list.clear(); list.push_top(&m);list.push_top(&d);list.push_top(&e); list.push_bottom(&g);list.push_top(&b);list.push_bottom(&f); cout<<"T-> ";list.printTtB(" ");cout<<"<-B"< ";list.printBtT(" ");cout<<"<-T"< ";list.printTtB(" ");cout<<"<-B"< ";list.printBtT(" ");cout<<"<-T"< e d <-B list.swapNode(list.top(),list.bottom());//a before b//now T-> d e <-B list.swapNode(list.bottom(),list.top());//b before a//expect the same as starting, since we swap two times: T-> e d <-B cout<<"T-> ";list.printTtB(" ");cout<<"<-B"< ";list.printBtT(" ");cout<<"<-T"<next,list.bottom()); //before swap: T-> e d m g <-B //expect: T-> e g m d <-B cout<<"T-> ";list.printTtB(" ");cout<<"<-B"< ";list.printBtT(" ");cout<<"<-T"< m e g d <-B Node * tmp = list.bottom()->prev;list.removeNode(tmp);list.insertAfter(tmp,NULL); cout<<"T-> ";list.printTtB(" ");cout<<"<-B"< ";list.printBtT(" ");cout<<"<-T"< m g d e <- tmp = list.top()->next; list.removeNode(tmp); list.insertAfter(tmp,list.bottom()); cout<<"T-> ";list.printTtB(" ");cout<<"<-B"< ";list.printBtT(" ");cout<<"<-T"< m <-B cout<<"T-> ";list.printTtB(" ");cout<<"<-B"< ";list.printBtT(" ");cout<<"<-T"< b e d m g f <-B //expect after: T-> b d e f g m <-B list.sortByNameSelection(); list.sortByNameSelection();//sort on a sorted list cout<<"T-> ";list.printTtB(" ");cout<<"<-B"< ";list.printBtT(" ");cout<<"<-T"< m <-B cout<<"T-> ";list.printTtB(" ");cout<<"<-B"< ";list.printBtT(" ");cout<<"<-T"< 6 19 4 10 0 7 <-B //expect after: T-> 0 4 6 7 10 19 <-B list.sortBySizeSelection(); list.sortBySizeSelection();//sort on a sorted list cout<<"T-> ";list.printTtB(" ");cout<<"<-B"< ";list.printBtT(" ");cout<<"<-T"< m <-B cout<<"T-> ";list.printTtB(" ");cout<<"<-B"< ";list.printBtT(" ");cout<<"<-T"< b e d m g f <-B //expect after: T-> b d e f g m <-B list.sortByNameInsertion(); list.sortByNameInsertion();//sort on a sorted list cout<<"T-> ";list.printTtB(" ");cout<<"<-B"< ";list.printBtT(" ");cout<<"<-T"< f <-B, since we delete top which is d cout<<"T-> ";list.printTtB(" ");cout<<"<-B"< ";list.printBtT(" ");cout<<"<-T"< d <-B, since we delete bottom which is f cout<<"T-> ";list.printTtB(" ");cout<<"<-B"< ";list.printBtT(" ");cout<<"<-T"<e d m<-B list.deleteNode(list.top()->next); //expect after delete: T-> e m <-B cout<<"T-> ";list.printTtB(" ");cout<<"<-B"< ";list.printBtT(" ");cout<<"<-T"< true list.push_top(&m);list.push_top(&d); cout<<((list.search(list.top(),"a")==NULL)?true:false)< true cout<<((list.search(list.top(),"m")==NULL)?true:false)< false } } /* This function tests a basic functionality of your OS class. ------------------------------------------- - DO NOT CHANGE ANYTHING IN THIS FUNCTION - ------------------------------------------- */ void test_os(int argc, char** argv){ bool all = false; cout<