fixed RecursiveCreateDirectory()

svn path=/trunk/; revision=7701
This commit is contained in:
Martin Fuchs 2004-01-17 00:36:46 +00:00
parent 020f7d429d
commit f3077c25b9

View file

@ -266,12 +266,21 @@ BOOL RunDLL(HWND hwnd, LPCTSTR dllname, LPCSTR procname, LPCTSTR cmdline, UINT n
BOOL RecursiveCreateDirectory(LPCTSTR path_in) BOOL RecursiveCreateDirectory(LPCTSTR path_in)
{ {
TCHAR drive[_MAX_DRIVE], path[MAX_PATH], hole_path[MAX_PATH]; TCHAR path[MAX_PATH], hole_path[MAX_PATH];
_tcscpy(hole_path, path_in); _tcscpy(hole_path, path_in);
_tsplitpath(hole_path, drive, NULL, NULL, NULL); int drv_len = 0;
LPTSTR dir = hole_path + _tcslen(drive); LPCTSTR d;
for(d=hole_path; *d && *d!='/' && *d!='\\'; ++d) {
++drv_len;
if (*d == ':')
break;
}
LPTSTR dir = hole_path + drv_len;
int l; int l;
LPTSTR p = hole_path + (l=_tcslen(hole_path)); LPTSTR p = hole_path + (l=_tcslen(hole_path));
@ -284,13 +293,11 @@ BOOL RecursiveCreateDirectory(LPCTSTR path_in)
HANDLE hFind = FindFirstFile(hole_path, &w32fd); HANDLE hFind = FindFirstFile(hole_path, &w32fd);
if (hFind == INVALID_HANDLE_VALUE) { if (hFind == INVALID_HANDLE_VALUE) {
int i; _tcsncpy(path, hole_path, drv_len);
int i = drv_len;
_tcscpy(path, drive);
i = _tcslen(path);
for(p=dir; *p=='/'||*p=='\\'; p++) for(p=dir; *p=='/'||*p=='\\'; p++)
path[i++-1] = *p++; path[i++] = *p++;
for(; i<l; i++) { for(; i<l; i++) {
memcpy(path, hole_path, i); memcpy(path, hole_path, i);
@ -307,9 +314,12 @@ BOOL RecursiveCreateDirectory(LPCTSTR path_in)
if (hFind != INVALID_HANDLE_VALUE) if (hFind != INVALID_HANDLE_VALUE)
FindClose(hFind); FindClose(hFind);
else else {
LOG(FmtString(TEXT("CreateDirectory(\"%s\")"), path));
if (!CreateDirectory(path, 0)) if (!CreateDirectory(path, 0))
return FALSE; return FALSE;
}
} }
} else } else
FindClose(hFind); FindClose(hFind);