[shellpath.c]: minor fix to Rolf's patch

Rolf Kalbermatter rolf.kalbermatter at citeng.com
Tue Nov 2 02:30:58 CST 2004

<menard.fabrice at wanadoo.fr> wrote:

>The latest patch from Rolf Kalbermatter on shellpath.c was breaking the installation of wine.inf.
> wine rundll32 setupapi.dll,InstallHinfSection DefaultInstall 128 d:\\wine.inf
>was returning errors about being unable to create some dirs.  In facts these errors was concerning 
>already existing directories in SHGetFolderPathW.

I believe this patch is not fully correct. I noticed these errors too after the patch was applied,
but did a little more investigation. SHCreateDirectoryEx should never be called if the directory
already exists since this is explicitedly tested before the call to the function with PathFileExistsW().

Also inside the SHCreateDirectoryEx function I saw that the first call to CreateDirectory fails since
intermediate directories are missing and then in the recursive call to CreateDirectory every single
call returns ERROR_ALREAY_EXISTS on my system in spite of that it actually creates the last two or
three directories in there.

My investigations showed that in spite of that some of the the top level directories do not exist, the
function NtCreateFile() which is ultimately called does seem to return an according NT status when
called from SHGetFolderPath() but does create the directory nevertheless.

Strange thing is that I can't reproduce this behaviour when calling SHCreateDirectoryEx() with many
different parameters from an extended test in tests/shfileop.c

So I believe the root cause really seems somewhere else, namely NTCreateFile or maybe wineserver itself,
but I hadn't time to further go into details.

>I think it is not necessary to care about that in this function so I added a check on the
>type of error returned by SHCreateDirectoryExW. 

ShCreateDirectory should fail with that error if the directory really already existed.

Rolf Kalbermatter

More information about the wine-devel mailing list