标签:
1 void CreateDir(const string& strPath) 2 { 3 if (PathFileExists(strPath.c_str())) 4 { 5 return; 6 } 7 8 size_t sPrePos = 0; 9 string strTmp = ""; 10 size_t sPos = strPath.find(‘\\‘); 11 if (sPos == string::npos) 12 { 13 return; 14 } 15 16 strTmp = strPath.substr(0, sPos + 1); 17 if ( !PathFileExists( strTmp.c_str() ) ) 18 { 19 return; 20 } 21 22 sPrePos = sPos + 1; 23 sPos = strPath.find(‘\\‘, sPrePos); 24 while (sPos != string::npos) 25 { 26 strTmp = strPath.substr(0, sPos); 27 if (!PathFileExists(strTmp.c_str())) 28 { 29 CreateDirectory(strTmp.c_str(), NULL); 30 } 31 32 sPrePos = sPos + 1; 33 sPos = strPath.find(‘\\‘, sPrePos); 34 } 35 36 if (!PathFileExists(strPath.c_str())) 37 { 38 CreateDirectory(strPath.c_str(), NULL); 39 } 40 41 }
标签:
原文地址:http://www.cnblogs.com/liuxupiaoshi/p/4239882.html