123456789101112131415161718192021222324252627282930313233343536373839 |
- // stdafx.cpp : 只包括标准包含文件的源文件
- // TestWizard.pch 将作为预编译头
- // stdafx.obj 将包含预编译类型信息
- #include "stdafx.h"
- // TODO: 在 STDAFX.H 中
- // 引用任何所需的附加头文件,而不是在此文件中引用
- bool MKDIR(LPCTSTR dir)
- {
- int nleft = 0;
- int nIndex = -1;
- std::string strdir = dir;
- strdir = strdir.substr(0, strdir.find_last_of(_T("\\")));
- if (strdir.at(strdir.size() - 1) != _T('\\'))
- strdir.append(_T("\\"));
- // 共享路径和硬盘盘符;
- if (_tcscmp(strdir.substr(0, 2).c_str(), _T("\\\\")) == 0)
- nleft = strdir.find_first_of(_T("\\"), 2) + 1; // 去除共享主机名;
- else if (strdir.at(2) == _T('\\'))
- nleft = 3;
- do {
- nIndex = strdir.substr(nleft, -1).find_first_of(_T("\\"));
- if (nIndex != std::string::npos) {
- if (_mkdir(strdir.substr(0, nIndex + nleft).c_str()) == -1 && (errno != EEXIST)) {
- return false;
- }
- nleft += nIndex + 1;
- }
- } while (nIndex != -1);
- return true;
- };
|