1 /*创建多级目录*/ 2 int CreateDir(const char *sPathName) 3 { 4 char DirName[256]={0}; 5 strcpy(DirName, sPathName); 6 int len = strlen(DirName); 7 for (int i=1; i<len; i++){ 8 if (DirName[i]!='/'){ 9 continue; 10 } 11 DirName[i] = 0; 12 if (access(DirName, NULL)!=0 && mkdir(DirName)==-1) 13 { 14 return -1; 15 } 16 DirName[i] = '/'; 17 } 18 19 return 0; 20 }