MakeSureDirectoryPathExists: Recursively create path up to last '\\'.
diff --git a/dlls/dbghelp/path.c b/dlls/dbghelp/path.c
index c8a1a65..6164033 100644
--- a/dlls/dbghelp/path.c
+++ b/dlls/dbghelp/path.c
@@ -91,13 +91,26 @@
*/
BOOL WINAPI MakeSureDirectoryPathExists(LPCSTR DirPath)
{
- if (CreateDirectoryA(DirPath, NULL)) return TRUE;
- if (GetLastError() == ERROR_ALREADY_EXISTS)
+ char path[MAX_PATH];
+ const char *p = DirPath;
+ int n;
+
+ if (p[0] && p[1] == ':') p += 2;
+ while (*p == '\\') p++; /* skip drive root */
+ while ((p = strchr(p, '\\')) != NULL)
{
- SetLastError(ERROR_SUCCESS);
- return TRUE;
+ n = p - DirPath + 1;
+ memcpy(path, DirPath, n);
+ path[n] = '\0';
+ if( !CreateDirectoryA(path, NULL) &&
+ (GetLastError() != ERROR_ALREADY_EXISTS))
+ return FALSE;
+ p++;
}
- return FALSE;
+ if (GetLastError() == ERROR_ALREADY_EXISTS)
+ SetLastError(ERROR_SUCCESS);
+
+ return TRUE;
}
/******************************************************************