Use SHCreateDirectoryEx function instead of doing explicit recursive
directory creation.
This commit is contained in:
parent
a2ebf8b356
commit
e50a27de04
|
@ -1573,7 +1573,6 @@ HRESULT WINAPI SHGetFolderPathW(
|
||||||
WCHAR szBuildPath[MAX_PATH], szTemp[MAX_PATH];
|
WCHAR szBuildPath[MAX_PATH], szTemp[MAX_PATH];
|
||||||
DWORD folder = nFolder & CSIDL_FOLDER_MASK;
|
DWORD folder = nFolder & CSIDL_FOLDER_MASK;
|
||||||
CSIDL_Type type;
|
CSIDL_Type type;
|
||||||
WCHAR *p;
|
|
||||||
|
|
||||||
TRACE("%p,%p,nFolder=0x%04x\n", hwndOwner,pszPath,nFolder);
|
TRACE("%p,%p,nFolder=0x%04x\n", hwndOwner,pszPath,nFolder);
|
||||||
|
|
||||||
|
@ -1657,39 +1656,16 @@ HRESULT WINAPI SHGetFolderPathW(
|
||||||
}
|
}
|
||||||
|
|
||||||
/* create directory/directories */
|
/* create directory/directories */
|
||||||
p = strchrW(szBuildPath, '\\');
|
if (SHCreateDirectoryExW(hwndOwner, szBuildPath, NULL))
|
||||||
while (p)
|
|
||||||
{
|
{
|
||||||
*p = 0;
|
ERR("Failed to create directory '%s'.\n", debugstr_w(szBuildPath));
|
||||||
if (!PathFileExistsW(szBuildPath))
|
hr = E_FAIL;
|
||||||
{
|
goto end;
|
||||||
TRACE("Creating directory %s\n", debugstr_w(szBuildPath));
|
|
||||||
if (!CreateDirectoryW(szBuildPath,NULL))
|
|
||||||
{
|
|
||||||
ERR("Failed to create directory '%s'.\n",
|
|
||||||
debugstr_w(szBuildPath));
|
|
||||||
hr = E_FAIL;
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*p = '\\';
|
|
||||||
p = strchrW(p+1, '\\');
|
|
||||||
}
|
|
||||||
/* last component must be created too. */
|
|
||||||
if (!PathFileExistsW(szBuildPath))
|
|
||||||
{
|
|
||||||
if (!CreateDirectoryW(szBuildPath,NULL))
|
|
||||||
{
|
|
||||||
ERR("Failed to create directory '%s'.\n", debugstr_w(szBuildPath));
|
|
||||||
hr = E_FAIL;
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TRACE("Created missing system directory '%s'\n", debugstr_w(szBuildPath));
|
TRACE("Created missing system directory '%s'\n", debugstr_w(szBuildPath));
|
||||||
end:
|
end:
|
||||||
TRACE("returning 0x%08lx (final path is %s)\n", hr,
|
TRACE("returning 0x%08lx (final path is %s)\n", hr, debugstr_w(szBuildPath));
|
||||||
debugstr_w(szBuildPath));
|
|
||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue