mkdir.c

来自「This is to bulid a sample linux shell.」· C语言 代码 · 共 32 行

C
32
字号
#include<stdio.h>#include<sys/types.h>#include<unistd.h>#include<string.h>#include<sys/stat.h>#include<stdlib.h>#if defined (BSD) && !_POSIX_SOURCE #include<sys/dir.h> typedef struct direct Dirent;#else #include<dirent.h> typedef struct dirent Dirent;#endifmain(int argc ,char *argv[]) {  Dirent *dp;  DIR *dir_fdesc;  int i,cnt;  if(argc==1)  //check for the file name  {  printf("USAGE: mkdir <filename>\n");     exit(0);   } for(i=0;i<argc;i++)  //open all the directory in given filenames  { if(!(dir_fdesc=opendir(argv[i])))   {     if(mkdir(argv[i],S_IRWXU|S_IRWXG|S_IRWXO)==-1);//this be the default directory modes     printf("Perror-opendir\n");   }   }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?