bool CreateDirectory(const char* vPath)
{
if(0 == vPath) return false;
if(255 < strlen(vPath)) return false;
SECURITY_ATTRIBUTES sa;
sa.bInheritHandle = false;
sa.lpSecurityDescriptor = NULL;
sa.nLength = sizeof(SECURITY_ATTRIBUTES);
BOOL bRet = CreateDirectory(vPath,&sa);
int iErr = GetLastError();
if((ERROR_ALREADY_EXISTS == iErr) || (0 != bRet))
return true;
if(iErr == ERROR_PATH_NOT_FOUND)
{
string strPath = vPath;
string strTemp;
int iPos = strPath.find('\\',0);
iPos = strPath.find('\\',iPos+1);
whild(-1 != iPos)
{
strTemp = strPath;
strTemp[iPos] = 0;
if(false == CreateDirectory(strTemp.c_str()))
return false;
iPos = strPath.find('\\',iPos+1);
}
CreateDirectory(vPath);
}
return true;
}
创建文件夹
最新推荐文章于 2022-12-13 17:36:20 发布