• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ cd函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中cd函数的典型用法代码示例。如果您正苦于以下问题:C++ cd函数的具体用法?C++ cd怎么用?C++ cd使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: Comando_Terminal_Local

int Comando_Terminal_Local(int conexao,char *param,int tipo){
  int ret;
   if(tipo==CD){
	   if(ret=cd(param)==-1) printf("Diretório inexistente ou sem acesso\n");
   }
   else ls(param);
   
   if(param!=NULL) strcpy(param,"");
  return;  	     

}
开发者ID:JackLima8,项目名称:Redes-1,代码行数:11,代码来源:lib_ftp.c


示例2: popd

int popd(Stack *in){
	if(in->top == -1){
		return EXIT_FAILURE;
	}
	else{
		char *temp = in->stack[in->top--];
		cd(temp);
		free(temp);
		return EXIT_SUCCESS;
	}
}
开发者ID:en4bz,项目名称:bell,代码行数:11,代码来源:builtins.c


示例3: QDir

QString Paths::resourceDir(const QString& file)
{
  auto resourceDir = QDir(QGuiApplication::applicationDirPath());

#ifdef Q_OS_MAC
  resourceDir.cdUp();
  resourceDir.cd("Resources");
#endif

  return resourceDir.filePath(file);
}
开发者ID:rjshaver,项目名称:plex-media-player,代码行数:11,代码来源:Paths.cpp


示例4: TEST

TEST(CompressedMatrix, CopyConstructor)
{
    CompressedMatrix<int> ci(3, 3);
    ci[0][0] = 1;
    ci[1][1] = 2;
    ci[2][2] = 3;

    CompressedMatrix<double> cd(ci);

    EXPECT_EQ(ci, cd);
}
开发者ID:WesleyCeraso,项目名称:algorithms,代码行数:11,代码来源:test_compressedmatrix.cpp


示例5: touchTest

//This tests touch and creat
//First test makes sure the mtime changes on a file that exists.
//Returns 0 if the time isnt greater than what it was before.
//Second test touches a file that doesnt exits, and therefore makes one.
//Checks the inode of the new file, and if isn't what is expected, returns zero.
//This second test checks both if touch and creat are working.
int touchTest()
{
  MINODE *test_mip = running->cwd;
  INODE *ip = NULL;
  int ino = 0;
  int old = 0;
  int expected1 = 28;

  strcpy(pathname, "");
  cd(pathname);
  test_mip = running->cwd;
  printf("\n\n-------- TESTING TOUCH FUNCTION --------\n\n");

  strcpy(pathname, "tiny");
  ino = getino(test_mip, pathname);
  test_mip = iget(dev, ino);
  ip = &test_mip->INODE;

  old = ip->i_mtime;
  printf("tiny's current mtime = %d\n", ip->i_mtime);
  printf("Testing >touch tiny\n");
  strcpy(pathname, "tiny");
  touch_file(pathname);
  printf("tiny's new mtime = %d\n", ip->i_mtime);

  if(ip->i_mtime > old)
    printf("TEST PASSED!\n\n");
  else
  {
    printf("TEST FAILED!\n\n");
    return 0;
  }


  test_mip = running->cwd;
  printf("Testing >touch newfile\n");
  strcpy(pathname, "newfile");
  touch_file(pathname);

  strcpy(pathname, "newfile");
  ino = getino(test_mip, pathname);
  printf("Expected ino of newfile = %d\n", expected1);
  printf("Actual ino of newfile = %d\n", ino);
  if (ino != expected1)
  {
    printf("TEST FAILED!\n\n");
    return 0;
  }
  printf("TEST PASSED!\n\n");

  printf("\nALL TOUCH TESTS PASSED!\n\n\n");
	return 1;
}
开发者ID:dbhoekman,项目名称:CS360,代码行数:59,代码来源:tests.c


示例6: pushd

int pushd(int argc, char** argv) {
	if (top==MAX_DIRECTORY_STACK) {
		fprintf(stderr,"%s: cannot pushd: directory stack full\n",shellname);
		return 1;
	} else {
		dstack[top]=getcwd(malloc(PATH_MAX),PATH_MAX); // push current directory to stack
		top++;
		cd(argc,argv); // change to requested directory
		dirs(1,NULL);  // stat stack status
	}
	return 0;
}
开发者ID:marcsances,项目名称:zesh,代码行数:12,代码来源:builtins.c


示例7: find_and_exec

//big ass switchy thingy
int find_and_exec(const char * command_name, const char * parameters){
  int ret;
  if(command_name == NULL){
    return 0;
  }
  else if(strcmp(command_name,"pwd") == 0){
    return pwd();
  }
  else if(strcmp(command_name,"cd") == 0){
    return cd(parameters);
  }
  else if(strcmp(command_name,"echo") == 0){
    return echo(parameters);
  }
  else if(strcmp(command_name,"pushd") == 0){
    return pushd(parameters);
  }
  else if(strcmp(command_name,"popd") == 0){
    return popd();
  }
  else if(strcmp(command_name,"exit") == 0){
    exitc(parameters);
  }
  else if(strcmp(command_name,"set") == 0){
    printf("Did you mean export? If you are looking for windows try your walls\n");
    return 0;
  }
  else if(strcmp(command_name,"history") == 0){
    print_stack_lines(history);
    return 0;
  }
  else if(strcmp(command_name,"unsetenv") == 0){
    return unsetenv(parameters);
  }
  else {
    int pid = fork();
    if(pid == -1){return 1;}
    else if(pid == 0){
      if(parameters == NULL) {
        execlp(command_name,command_name,NULL);
      }
      else {
        execvp(command_name,split_spaces_cmd(command_name,parameters));
      }
    }
    else {
      wait(&ret);
      return ret;
    }
  }
  return 0;
}
开发者ID:StephenHamilton,项目名称:Comp310-assignment-1,代码行数:53,代码来源:simple.c


示例8: createTestDir

QDir createTestDir()
{
	auto tempDir = QDir::temp();
	
	QProcess process;
	process.start("rm -rf " + tempDir.filePath("test"));
	process.waitForFinished();
	
	tempDir.mkdir("test");
	tempDir.cd("test");
	
	return tempDir;
}
开发者ID:h2so5,项目名称:PaintField,代码行数:13,代码来源:testutil.cpp


示例9: start

void start(bool read_from_file)
{
	cd(""); // let shell starts from home

	if(read_from_file){
		// file processing functions should be called from here

		shell_loop(true);
	}
	else{
		shell_loop(false);
	}
}
开发者ID:KhaledEl-Tahan,项目名称:shell,代码行数:13,代码来源:main.c


示例10: execute_non_forking

int execute_non_forking(char **subcmd){
	int retval;
	char *cmd = subcmd[0];
	char **args = &subcmd[1];
	if (strcmp(cmd, "exit") == 0) {
		retval = exit_shell();
	} else if (strcmp(cmd, "cd") == 0) {
		retval = cd(args[0]);
	} else {
		retval = 2;
	}
	return retval;
}
开发者ID:cop4610t-cool-group,项目名称:project1,代码行数:13,代码来源:execute.c


示例11: main

/**
 * Quash entry point
 *
 * @param argc argument count from the command line
 * @param argv argument vector from the command line
 * @return program exit status
 */
int main(int argc, char** argv) { 
    command_t cmd; //< Command holder argument
      
    start();
    struct sigaction NULL_sa;
    struct sigaction sa;
    sigset_t mask_set;
    sigfillset(&mask_set);
    sigdelset(&mask_set,SIGINT);
    sigdelset(&mask_set,SIGTSTP);
    sa.sa_handler = catchChild;
    sigprocmask(SIG_SETMASK, &mask_set, NULL);
    //TODO: this is involved withe the error 10 problem. Removing it remedies the issue for now but breaks other things.
    sigaction(SIGCHLD, &sa,NULL);//child termination calls catchChild;

    setenv( "WKDIR", getenv("HOME"), 1 );

    puts("hOi! Welcome to Quash!");

    // Main execution loop
    while (is_running()) 
    {
        // NOTE: I would not recommend keeping anything inside the body of
        // this while loop. It is just an example.

        // The commands should be parsed, then executed.
        if( !get_command(&cmd, stdin) );
        else if (!strcmp(cmd.cmdstr, "q")||!strcmp(cmd.cmdstr, "exit")||!strcmp(cmd.cmdstr, "quit"))
            terminate(); // Exit Quash
        else if(!strcmp(cmd.execArgs[0], "set"))
            set(cmd);//set environment variables
        else if(!strcmp(cmd.execArgs[0], "echo"))
            echo(cmd);//echos environment variables
        else if(!strcmp(cmd.execArgs[0], "pwd"))
            pwd(cmd);//prints current working directory
        else if(!strcmp(cmd.execArgs[0], "cd"))
            cd(cmd);//changes the working directory
        else if(!strcmp(cmd.execArgs[0], "jobs"))
            jobs();//prints out a list of currently running jobs
        else if(!strcmp(cmd.execArgs[0], "kill"))
            killChild(cmd);//kills specified job
        else if (!strcmp(cmd.execArgs[0], "wait"))
            sleep(atoi(cmd.execArgs[1]));
        else if (strchr(cmd.cmdstr,'|')!= NULL)
            exec_pipes(cmd);//executes piped commands
        else 
            exec_cmd(cmd);//executes normal commands
    }

    return EXIT_SUCCESS;
}
开发者ID:elisemmc,项目名称:EECS678_Projects,代码行数:58,代码来源:quash.c


示例12: mkdir

		 mkdir(char *dname){                                         //WORKS!!!
			 char *FileName;
			 struct NODE *temp;
			 temp = cwd;
			 strcpy(bname, basename(dname));
			 if(0 == strcmp(basename(dname), "/")){
				 //      printf("cannot create directory '/'");
				 return 0;
			 }
			 if(!dname || bname[0] == '.' || bname[0] == '/'){
				 return 0;
			 }
			 char *character = dirname(dname);
			 if(strcmp(character, ".")){
				 printf("%s\n", character);
				 if(cd(&temp, character) == 0){
					 printf("mkdir: cannot create directory '%s': directory does not exist\n", dname);
					 return 0;
				 };
			 }
			 //  printf("%s ###: ", character);
			 //  pwd(temp);
			 //  printf(" ###\n");
			 //  printf("Dir: '%s' File: '%s'\n",dname, bname);
			 if(temp->childPtr == NULL){      
				 temp->childPtr = (struct NODE *)malloc(sizeof(struct NODE));
				 strcpy(temp->childPtr->Name, bname);
				 temp->childPtr->parentPtr = temp;
				 strcpy(temp->childPtr->Type, "D");
			 }
			 else{
				 temp = temp->childPtr;
				 if(0 == strcmp(temp->Name, bname)){
					 printf("mkdir: cannot create directory '%s': directory exists\n", bname);
					 return 0;
				 }
				 while(temp->siblingPtr != NULL){
					 temp = temp->siblingPtr;
					 //   printf("%s != %s\n", temp->Name, dname);
					 if(0 == strcmp(temp->Name, bname)){
						 printf("mkdir: cannot create directory '%s': directory exists\n", dname);
						 return 0;
					 }
				 }
				 temp->siblingPtr = (struct NODE *)malloc(sizeof(struct NODE));
				 strcpy(temp->siblingPtr->Name, bname);
				 temp->siblingPtr->parentPtr = temp->parentPtr;
				 strcpy(temp->siblingPtr->Type, "D");
			 }
			 //printf("Directory: %s Created.\n", dname);
		 }
开发者ID:zeke225,项目名称:cs360,代码行数:51,代码来源:lab2v11.c


示例13: main

int main(int argc, char *argv[]) {
    char *delimiter_position = NULL;
    char *command = NULL;
    int i = 0;
    if (argc < 2) {
        while(1) {
            if (getcwd(current_work_path, sizeof(current_work_path)) == NULL) {
                break;
            }
            if (getlogin_r(user, sizeof(user)) != 0) {
                break;
            }

            sprintf(PS1, "%s:%s$ ", user, current_work_path);

            if (command != NULL) {
                free(command);
                command = NULL;
            }
            
            command = readline(PS1);
            if ((command != NULL) && (*command != '\0')) {
                add_history(command);
            }
            
            delimiter_position = strtok(command, " ");
            while (delimiter_position != NULL) {
                argv[i++] = delimiter_position;
                delimiter_position = strtok(NULL, " ");
            }
            argv[i] = NULL;
            i = 0;
            
            if (strcmp(argv[0], "quit") == 0) {
                break;
            }
            
            if (strcmp(argv[0], "cd") == 0) {
                cd(argv);
                continue;
            }

            execute(argv);
        }
    } else {
        readopt(argc, argv);
    }

    
    return 0;
}
开发者ID:Tyrion-Lannister-274AL,项目名称:tsh,代码行数:51,代码来源:main.c


示例14: cd

void MainWindow::connect2mysql() {
    ConnectDialog cd(this);
    cd.readSettings();

    if ( cd.exec() == QDialog::Accepted ) {
       cd.writeSettings();
       try {
           md = cd.getConnection();
           QMessageBox::information(this, "Connected", "Connected to MYSQL!");
       } catch ( std::exception & e ) {
           QMessageBox::warning(this, "Failed", e.what());
       }
    }
}
开发者ID:lusaisai,项目名称:myWeb0.2,代码行数:14,代码来源:mainwindow.cpp


示例15: copy_from_ordered_range

void
PB_DS_CLASS_C_DEC::
copy_from_ordered_range(It first_it, It last_it, It other_first_it, 
			It other_last_it)
{
  clear();
  const size_type len = std::distance(first_it, last_it) 
    		         + std::distance(other_first_it, other_last_it);

  value_vector a_values = s_value_alloc.allocate(len);

  iterator target_it = a_values;
  It source_it = first_it;
  It source_end_it = last_it;

  cond_dtor<size_type> cd(a_values, target_it, len);
  while (source_it != source_end_it)
    {
      new (const_cast<void* >(static_cast<const void* >(target_it)))
	value_type(*source_it++);
      ++target_it;
    }

  source_it = other_first_it;
  source_end_it = other_last_it;

  while (source_it != source_end_it)
    {
      new (const_cast<void* >(static_cast<const void* >(target_it)))
	value_type(*source_it++);
      ++target_it;
    }

  reallocate_metadata((node_update* )this, len);
  cd.set_no_action();
  m_a_values = a_values;
  m_size = len;
  m_end_it = m_a_values + m_size;
  update(PB_DS_node_begin_imp(), (node_update* )this);

#ifdef _GLIBCXX_DEBUG
  const_iterator dbg_it = m_a_values;
  while (dbg_it != m_end_it)
    {
      map_debug_base::insert_new(PB_DS_V2F(*dbg_it));
      dbg_it++;
    }
  PB_DS_CLASS_C_DEC::assert_valid();
#endif 
}
开发者ID:Butterfly-3Kisses,项目名称:DC24Badge,代码行数:50,代码来源:constructors_destructor_fn_imps.hpp


示例16: cd

bool CacheManager::addEmptyEntry(const std::string& name) {
    if (entryExists(name)) {
        return false;
    }

    std::unique_ptr<CacheData> cd(new CacheData);
    cd->createEmpty(name, entry_counter_++);

    cache_map_[name] = std::move(cd);

    addDirectories(name);

    return true;
}
开发者ID:shuc324,项目名称:hhvm,代码行数:14,代码来源:cache-manager.cpp


示例17: cd

void collision_detection::CollisionWorldFCL::checkRobotCollisionHelper(const CollisionRequest &req, CollisionResult &res, const CollisionRobot &robot, const robot_state::RobotState &state, const AllowedCollisionMatrix *acm) const
{
  const CollisionRobotFCL &robot_fcl = dynamic_cast<const CollisionRobotFCL&>(robot);
  FCLObject fcl_obj;
  robot_fcl.constructFCLObject(state, fcl_obj);
  
  CollisionData cd(&req, &res, acm);
  cd.enableGroup(robot.getRobotModel());
  for (std::size_t i = 0 ; !cd.done_ && i < fcl_obj.collision_objects_.size() ; ++i)
    manager_->collide(fcl_obj.collision_objects_[i].get(), &cd, &collisionCallback);
  
  if (req.distance)
    res.distance = distanceRobotHelper(robot, state, acm);
}
开发者ID:mpomarlan,项目名称:moveit_puzzle_demo,代码行数:14,代码来源:collision_world_fcl.cpp


示例18: main

int main(int argc, char** argv)
{
    QApplication qapp(argc, argv);
    KComponentData cd("graphicsview-test");

    Calligra::Sheets::Part part;
    Calligra::Sheets::Doc doc(&part);
    part.setDocument(&doc);


    bool ok = doc.openUrl(QUrl("/home/marijn/kde/src/calligra/docs/oos_AMSAT-IARU_Link_Model.ods"));
    if (!ok) {
        qDebug() << "failed to load";
        return 0;
    }

    QFont font(KoGlobal::defaultFont());

    Calligra::Sheets::CanvasItem* canvas = new Calligra::Sheets::CanvasItem(&doc);

    QRect usedArea = canvas->activeSheet()->usedArea(true);
    QFontMetricsF fm(font, 0);
    QSizeF size(canvas->activeSheet()->columnPosition(usedArea.right()+3), canvas->activeSheet()->rowPosition(usedArea.bottom()+5));
    canvas->setDocumentSize(size);
    size = canvas->zoomHandler()->documentToView(size);
    canvas->resize(size);
    canvas->setPos(0, 0);

    Calligra::Sheets::ColumnHeaderItem* columnHeader = static_cast<Calligra::Sheets::ColumnHeaderItem*>(canvas->columnHeader());
    static_cast<QGraphicsWidget*>(columnHeader)->resize(size.width(), fm.height() + 3);
    columnHeader->setPos(0, -columnHeader->height());

    Calligra::Sheets::RowHeaderItem* rowHeader = static_cast<Calligra::Sheets::RowHeaderItem*>(canvas->rowHeader());
    static_cast<QGraphicsWidget*>(rowHeader)->resize(fm.width(QString::fromLatin1("99999")) + 3, size.height());
    rowHeader->setPos(-rowHeader->width(), 0);

    columnHeader->toolChanged("PanTool");
    rowHeader->toolChanged("PanTool");
    
    QGraphicsScene scene;
    scene.addItem(canvas);
    scene.addItem(columnHeader);
    scene.addItem(rowHeader);

    QGraphicsView view(&scene);
    view.show();

    qapp.exec();
}
开发者ID:TheTypoMaster,项目名称:calligra,代码行数:49,代码来源:TestGraphicsView.cpp


示例19: putty_cd

euint8 putty_cd(euint8* path)
{
	SDfolder original;original = currDir;/*Backup*/
	if(path[0]=='/')
	{
		//absolute address
		currDir = root;//move back to the root folder then we can begin
		strChomp(path);
	}
	else
	{
		//relative address
	}
	/*new we pass through the strings section by section attempting to move*/

	printf("-->%s\n",path);
	char* tokens[20];
   	euint8 count = string_parser2(path,tokens);
   	euint8 i=0;
   	euint8 abort=0;
   	for(i=0;i<count;i++)
   	{
	   printf("->%s\n", tokens[i]);
	   if(abort==0)
	   {
			if(cd( tokens[i])!=0)
			{
			   abort=1;
			}
			free(tokens[i]);
   	   }
   if(abort==1)
   {
	   currDir = original;
	   return -1;
   }
   else
		return 0;
}
/*Removes the first char from a string*/
void strChomp(euint8* s)
{
	euint32 i=0;
	for(i=1;i<strlen(s);i++)
	{
		s[i-1]=s[i];
	}
	s[i-1]=0;//move the null
}
开发者ID:JesseNolan,项目名称:FAT32_Filesystem,代码行数:49,代码来源:FAT.c


示例20: allocSelfCollisionBroadPhase

double collision_detection::CollisionRobotFCL::distanceSelfHelper(const planning_models::KinematicState &state,
        const AllowedCollisionMatrix *acm) const
{
    FCLManager manager;
    allocSelfCollisionBroadPhase(state, manager);

    CollisionRequest req;
    CollisionResult res;
    CollisionData cd(&req, &res, acm);
    cd.enableGroup(getKinematicModel());

    manager.manager_->distance(&cd, &distanceCallback);

    return res.distance;
}
开发者ID:jonbinney,项目名称:moveit-core,代码行数:15,代码来源:collision_robot.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ cdCanvasForeground函数代码示例发布时间:2022-05-30
下一篇:
C++ ccw函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap