Linux C创建多级目录代码

Linux C创建多级目录代码:

int CreateDirectoryEx( char *sPathName )   {       char DirName[256];           strcpy(DirName,sPathName);           int i,len = strlen(DirName);           if(DirName[len-1]!='/')           strcat(DirName,"/");                 len = strlen(DirName);           for(i=1;i<len;i++)           {               if(DirName[i]=='/')               {                   DirName[i] = 0;                   if(access(DirName,NULL) != 0)                   {                       if(mkdir(DirName,0777) == -1)                       {                            perror("mkdir error");                            return -1;                        }                   }                 DirName[i] = '/';                }         }           return 0;       }  

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/912a1b63c03371fbcecbcd29a799b865.html