当前位置: 首页>>代码示例>>C++>>正文


C++ inode_state::setCwd方法代码示例

本文整理汇总了C++中inode_state::setCwd方法的典型用法代码示例。如果您正苦于以下问题:C++ inode_state::setCwd方法的具体用法?C++ inode_state::setCwd怎么用?C++ inode_state::setCwd使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在inode_state的用法示例。


在下文中一共展示了inode_state::setCwd方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: fn_cd

void fn_cd (inode_state& state, const wordvec& words){
   DEBUGF ('c', state);
   DEBUGF ('c', words);
   /*
   if(words.size() > 1) {
      wordvec nav_path = split(words[1], "/");
      state.final_cd(nav_path);
   } else {
      wordvec root_dir{};
      state.final_cd(root_dir);
   }
   */
   if(words.size() > 2){
      complain() << "cd: Too many arguments" << endl;
      return;
   }
   if(words.size() > 1) path_name_set(words.at(1));
   if(words.size() == 1){
      state.setCwd(state.get_root());
      return;
   } else if(words.at(1).at(0) == '/'){
      state.setCwd(state.get_root());
   }
   wordvec nav_path = split(words.at(1), "/");
   state.final_cd(nav_path);
}
开发者ID:ddsun95,项目名称:projects,代码行数:26,代码来源:commands.cpp

示例2: fn_rmr

void fn_rmr (inode_state& state, const wordvec& words){
   DEBUGF ('c', state);
   DEBUGF ('c', words);
   if(words.size() == 1){
      complain() << "rmr: Specify file name" << endl;
   } else if(words.size() > 2){
      complain() << "rmr: Too many arguments" << endl;
   } else if(words.at(1) == "." or words.at(1) == ".." or 
      (words.at(1).at(0) == '/' and words.at(1).length() == 1)){
      complain() << "rmr: Cannot remove directory" << endl;
   } else {
      path_name_set(words.at(1));
      const auto placeholder = state.get_cwd();
      if(words.at(1).at(0) == '/') state.setCwd(state.get_root());
      wordvec navpath = split(words[1], "/");
      string ffname = navpath.back();
      if(navpath.size() == 1){
         state.function_rmr(state.get_cwd(), ffname);
         return;
      }
      wordvec filepath(&navpath[0], &navpath[navpath.size() - 1]);
      state.function_final_rmr(ffname, filepath);
      state.setCwd(placeholder);
   }
}
开发者ID:ddsun95,项目名称:projects,代码行数:25,代码来源:commands.cpp

示例3: fn_cat

void fn_cat (inode_state& state, const wordvec& words){
   DEBUGF ('c', state);
   DEBUGF ('c', words);
   if(words.size() < 2){
      complain() << "cat: Too few arguments" << endl;
   } else {
      const string firstword = words.at(1);
      path_name_set(firstword);
      if(firstword.at(0) == '/' and firstword.length() > 1){
         string navname = firstword.substr(1, firstword.length());
         cout << navname << endl;
         const auto placeholder = state.get_cwd();
         wordvec nav_path {};
         nav_path = split(navname, "/");
         state.setCwd(state.get_root());
         state.final_func_cat(nav_path);
         state.setCwd(placeholder);
         return;
      } else if(firstword.length() == 1 and firstword.at(0) == '/'){
          complain() << "cat: /: File is Directory" << endl;
          return;
      }
      wordvec nav_path = split(firstword, "/");
      state.final_func_cat(nav_path);
   }
}
开发者ID:ddsun95,项目名称:projects,代码行数:26,代码来源:commands.cpp

示例4: fn_cd

void fn_cd (inode_state& state, const wordvec& words){
   DEBUGF ('c', state);
   DEBUGF ('c', words);
   inode_ptr ogcwd = state.getCwd();
   if (words.size() == 1){
      state.setCwd(state.getRoot()->getContents()->getNode("/"));
      return;
   }
   if (words.size() > 2) return;
   if (ogcwd == state.getRoot()->getContents()->getNode("/") && words[1] == "..") return;
   inode_ptr res = resolvePath(words[1], state.getCwd());
   if (res == nullptr) return;
   if (!res->isDirectory()) return;
   state.setCwd(res);
}
开发者ID:coltonUCSC,项目名称:cs109,代码行数:15,代码来源:commands.cpp

示例5: fn_make

void fn_make (inode_state& state, const wordvec& words){
   DEBUGF ('c', state);
   DEBUGF ('c', words);
   if(words.size() < 2){
      complain() << "make: Specify pathname" << endl;
      return;
   }
   const auto placeholder = state.get_cwd();
   if(words.at(1).at(0) == '/'){
      state.setCwd(state.get_root());
   }
   wordvec nav_path  = split(words[1], "/");
   wordvec insertion(&words[2], &words[words.size()]);
   state.final_make_file(nav_path, insertion);
   state.setCwd(placeholder);
}
开发者ID:ddsun95,项目名称:projects,代码行数:16,代码来源:commands.cpp

示例6: fn_ls

void fn_ls (inode_state& state, const wordvec& words){
   DEBUGF ('c', state);
   DEBUGF ('c', words);
   inode_ptr ogcwd = state.getCwd();
   inode_ptr res = ogcwd;
   if(words.size() > 1)
      res = resolvePath(words[1], state.getCwd());
   if (res == nullptr) return;
   auto pathList = res->getContents()->getAllPaths();
   state.setCwd(res);
   fn_pwd(state, words);
   for (size_t i = 0; i < pathList.size(); i++){
      cout << pathList[i] << endl;
   }
   state.setCwd(ogcwd);
}
开发者ID:coltonUCSC,项目名称:cs109,代码行数:16,代码来源:commands.cpp

示例7: fn_lsr

void fn_lsr (inode_state& state, const wordvec& words){
   DEBUGF ('c', state);
   DEBUGF ('c', words);

   inode_ptr ogcwd = state.getCwd();
   inode_ptr newCwd = ogcwd;
   if (words.size() > 0){
      newCwd = resolvePath(words[1], state.getCwd());
      state.setCwd(newCwd);
   }
   auto pathList = newCwd->getContents()->getAllDirs();
   wordvec ls {"ls"};
   fn_ls(state, ls);
   for(int i = 0; i < pathList.size(); i++){
      DFS(pathList[i], state);
   }
   state.setCwd(ogcwd);
}
开发者ID:coltonUCSC,项目名称:cs109,代码行数:18,代码来源:commands.cpp

示例8: fn_mkdir

void fn_mkdir (inode_state& state, const wordvec& words){
   DEBUGF ('c', state);
   DEBUGF ('c', words);
   //NEED TO CHECK IF THE DIR IS ALREADY IN THE DIR.
   if(words.size() < 2){
      complain() << "mkdir: Too few arguments" << endl;
   } else if(words.size() > 2) {
      complain() << "mkdir: Too many arguments" << endl;
   } else {
      path_name_set(words.at(1));
      const auto placeholder = state.get_cwd();
      if(words.at(1).at(0) == '/') {
         state.setCwd(state.get_root());
      }
      path_name_set(words.at(1));
      wordvec nav_path = split(words.at(1), "/");
      state.final_mkdir(nav_path);
      state.setCwd(placeholder);
   }
}
开发者ID:ddsun95,项目名称:projects,代码行数:20,代码来源:commands.cpp

示例9: DFS

void DFS(string s, inode_state& state){
   wordvec newLs {"ls", s};
   fn_ls(state, newLs);
   auto dirList = state.getCwd()->getContents()->getAllDirs();
   if (dirList.size() == 0)
      return;
   map<string, int> disc;
   for (int i = 0; i < dirList.size(); i++){
      disc[dirList[i]] = 0;
   }
   for (auto it = disc.begin(); it != disc.end(); ++it){
      if (it->second == 0){
     	disc[it->first] = 1;
     	inode_ptr ogcwd = state.getCwd();
     	state.setCwd(state.getCwd()->getContents()->getNode(it->first));
     	DFS(it->first, state);
     	state.setCwd(ogcwd);
      }
 	}
}
开发者ID:coltonUCSC,项目名称:cs109,代码行数:20,代码来源:commands.cpp

示例10: fn_lsr

void fn_lsr (inode_state& state, const wordvec& words){
   DEBUGF ('c', state);
   DEBUGF ('c', words);
   if(words.size() > 2){
      complain() << "lsr: Too many arguments" << endl;
      return;
   } else if(words.size() == 1){
      state.function_list_r(state.get_cwd());
   } else if(words.at(1).at(0) == '/'){
      if(words.at(1).length() == 1){
         state.function_list_r(state.get_root());
         return;
      }
      const auto placeholder = state.get_cwd();
      state.setCwd(state.get_root());
      wordvec nav_path = split(words.at(1), "/");
      state.function_list_r(state.get_working_ptr(nav_path));
      state.setCwd(placeholder);
   } else {
      wordvec nav_path = split(words[1], "/");
      state.function_list_r(state.get_working_ptr(nav_path));
   }
}
开发者ID:ddsun95,项目名称:projects,代码行数:23,代码来源:commands.cpp


注:本文中的inode_state::setCwd方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。