1 #include <iostream> 2 #include <stdlib.h> 3 #include <string> 4 #include <string.h> 5 6 using namespace std; 7 8 9 #pragma warning(disable: 4996) 10 11 12 #ifdef _WIN32 13 #include <direct.h> 14 #include <io.h> 15 #elif _LINUX 16 #include <stdarg.h> 17 #include <sys/stat.h> 18 #endif 19 20 #ifdef _WIN32 21 #define ACCESS _access 22 #define MKDIR(a) _mkdir((a)) 23 #elif _LINUX 24 #define ACCESS access 25 #define MKDIR(a) mkdir((a),0755) 26 #endif 27 28 29 30 int CreatDir( char *pDir ) 31 { 32 int i = 0; 33 int iRet; 34 int iLen; 35 char* pszDir; 36 37 if ( NULL == pDir ) 38 { 39 return 0; 40 } 41 42 int len = strlen( pDir ); 43 pszDir = new char[len+1]; 44 strcpy(pszDir,pDir); 45 46 iLen = strlen( pszDir ); 47 48 // 创建中间目录 49 for ( i = 0; i < iLen; i++ ) 50 { 51 if ( pszDir[i] == '\' || pszDir[i] == '/' ) 52 { 53 pszDir[i] = '