亚洲一级免费看,特黄特色大片免费观看播放器,777毛片,久久久久国产一区二区三区四区,欧美三级一区二区,国产精品一区二区久久久久,人人澡人人草

操作系統(tǒng)

linux語(yǔ)言中的mkdi函數(shù)

時(shí)間:2025-05-15 12:03:48 操作系統(tǒng) 我要投稿
  • 相關(guān)推薦

linux語(yǔ)言中的mkdi函數(shù)

  mkdir函數(shù)用于創(chuàng)建目錄。格式如下:

  #include

  #include

  #include

  int mkdir(const char *pathname,mode_t mode);

  其中參數(shù)pathname是新創(chuàng)建目錄的目錄名,mode指定該目錄的訪問(wèn)權(quán)限,這些位將受到文件創(chuàng)建方式屏蔽(umask)的修正。

  該函數(shù)創(chuàng)建一個(gè)名為pathname的空目錄,此目錄自動(dòng)含有“.”和“..”2個(gè)登記項(xiàng)。這個(gè)新創(chuàng)建目錄的用戶(hù)ID被設(shè)置為調(diào)用進(jìn)程的有效用戶(hù)ID,其組則為父目錄的組ID或者進(jìn)程的有效組ID。

  若調(diào)用成功,mkdir將更新該目錄的st_atime、st_ctime和st_mtime,同時(shí)更新其父目錄的st_ctime和st_mtime,然后返回0。若調(diào)用失敗,mkdir將返回-1.

  由pathname指定的新目錄的父目錄必須存在,并且調(diào)用進(jìn)程必須具有該父目錄的寫(xiě)權(quán)限以及pathname涉及的各個(gè)分路徑目錄的搜尋權(quán)限。

  rndir函數(shù)刪除一個(gè)空目錄,它的格式如下:

  #include

  int rmdir(const char *pathname);

  使用rmdir函數(shù)時(shí),目錄必須為空,否則調(diào)用失敗,函數(shù)返回-1.成功時(shí),函數(shù)返回0.

  例子:創(chuàng)建一個(gè)新目錄,然后刪除此目錄。

  復(fù)制代碼 代碼如下:

  #include

  #include

  #include

  #include

  int main(int argc,char *argv[])

  {

  char path[1000];

  char file[1000];

  /*

  if(argc!=2)

  {

  printf("Usage mkn");

  return 1;

  }

  */

  argv[1] = "test";

  getwd(path); //取得當(dāng)前工作目錄

  printf("current dirctory is:%sn",path);

  if(mkdir(argv[1],S_IRWXU|S_IRGRP|S_IXGRP|S_IROTH)<0)//創(chuàng)建新目錄

  {

  printf("mkdir failedn");

  return 2;

  }

  if(chdir(argv[1])<0) //改變當(dāng)前工作目錄為新目錄

  {

  printf("chdir failed n");

  return 3;

  }

  getwd(path);

  printf("mkdir successed.n New current directory is:%sn",path);

  //rmdir(path); //刪除新建目錄

  printf("%s is removedn",path);

  return 0;

  }

【linux語(yǔ)言中的mkdi函數(shù)】相關(guān)文章:

C語(yǔ)言中函數(shù)的區(qū)分08-30

C語(yǔ)言中isalnum()函數(shù)和isalpha()函數(shù)的對(duì)比10-12

C語(yǔ)言中g(shù)ets()函數(shù)知識(shí)08-10

C語(yǔ)言中關(guān)于時(shí)間的函數(shù)10-24

C語(yǔ)言中strpbr()函數(shù)的用法07-25

c語(yǔ)言中time函數(shù)的用法08-27

C語(yǔ)言中關(guān)于時(shí)間的函數(shù)08-19

Linux下精確控制時(shí)間的函數(shù)07-31

Linux系統(tǒng)調(diào)用設(shè)備的ioctl函數(shù)10-20