123456789101112131415161718192021222324252627282930313233343536373839 |
- #include "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;
- };
|