SHFileOperationW: Create subdir on Copy

Phillip Ezolt ezolt at fuse.zko.dec.com
Fri Jan 30 11:54:48 CST 2004


Hi All,

	Here's a small fix. Comments/questions are welcomed.

Summary
-------
	This patch allows SHFileOperationW to automatically create
subdirectories if they don't exists.  (The Microsoft documentation
states that this is correct.)

This patch fixes bug #1954.  I have verified that it works with
Today's CVS. (January 30,2004)

I ran into this problem with the Rollercoaster Tycoon demo installer.

It can successfully copy files to this newly created directory, but
coping into any (currently non-existant) directories below it fail.

According to MS:
(http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/reference/structures/shfileopstruct.asp)

        " Copy and Move operations can specify destination directories
that do not exist and the system will attempt to create them. "
(See footnote #1 for more info)

For example, this succeeds:
trace:shell:SHNotifyCopyFileW (L"E:\\WZS21db.tmp\\English\\rct.exe"
L"C:\\Program Files\\Hasbro Interactive\\RollerCoaster Tycoon Demo\\rct.exe" )

But this fails:
trace:shell:SHNotifyCopyFileW (L"E:\\WZS21db.tmp\\Saved Games\\001"
L"C:\\Program Files\\Hasbro Interactive\\RollerCoaster Tycoon Demo\\Saved
Games\\001" )

The directory "Saved Games" should be created before "001" is copied
into it.  Instead, the call fails.

--Phil

    Hewlett-Packard: High Performance Technical Computing/Visualization
---------------------------------------------------------------------------
Phillip.Ezolt at hp.com                                Performance/Development
-------------- next part --------------
? patch.diff
Index: dlls/shell32/shlfileop.c
===================================================================
RCS file: /home/wine/wine/dlls/shell32/shlfileop.c,v
retrieving revision 1.35
diff -u -r1.35 shlfileop.c
--- dlls/shell32/shlfileop.c	5 Jan 2004 21:13:37 -0000	1.35
+++ dlls/shell32/shlfileop.c	23 Jan 2004 21:39:44 -0000
@@ -1172,9 +1172,15 @@
 	    /* singlesource + no mask */
 	    if (-1 == (ToAttr & ToPathAttr))
 	    {
-                /* Target-dir does not exist, and cannot be created */
-                retCode=0x75;
-                goto shfileop_error;
+	      /* The destination directory for the file doesn't exist, create it. */
+                pToFile[0] = '\0';
+		if (SHCreateDirectoryExW(NULL,pTempTo, NULL))
+		  {
+		    // Target-dir does not exist, and cannot be created 
+		    retCode=0x75;
+		    goto shfileop_error;
+		  }
+                pToFile[0] = '\\';
 	    }
 
 	    switch(FuncSwitch)


More information about the wine-patches mailing list