示例#1
0
//DONEDONEDONEDONEDONEDONEDONE///////////////////////////////////////
void fn_ls (inode_state& state, const wordvec& words){
   bool r = false;
   string orig = pathname(state.get_contents().at("."),
                  state.get_root()->get_inode_nr());
   if (words.size() > 1) {
      for(auto word = words.begin()+1; word != words.end(); word++) {
         if((*word)[0] == '/') r = true;
         state.set_cwd(split(*word,"/"), r);
         print_dir(state);
         state.set_cwd(split(orig,"/"),true);
      }
   }
   else
      print_dir(state);         

   DEBUGF ('c', state);
   DEBUGF ('c', words);
}
示例#2
0
void fn_cd (inode_state& state, const wordvec& words){
   DEBUGF ('c', state);
   DEBUGF ('c', words);

   if(words.size() > 2)
      throw yshell_exn("Too many operands");

   inode_ptr cwd = state.get_cwd();
   state.set_cwd(cwd, words[1]);

   if(words[1] == "..") 
      {state.directory_path_name.pop_back();}

   else if (state.directory_path_name.size() > 1)
      {state.directory_path_name.push_back("/"+words[1]);}

   else if (state.directory_path_name.size() == 1)
      {state.directory_path_name.push_back(words[1]);} 
}