shell32: SHCreateDirectory and Win32DeleteFile changes

Rolf Kalbermatter r.kalbermatter at hccnet.nl
Thu Jan 23 05:21:19 CST 2003


Changelog
  * dlls/shell32/shlfileop.c
  * include/shlobj.h
  * dlls/shell32/shell32.spec
    Change SHCreateDirectory and Win32DeleteFile to be Unicode or ANSI depending
    on OS version. Add ShCreateDirectoryEx API  

License: X11/LGPL

Rolf Kalbermatter

Index: dlls/shell32/shlfileop.c
===================================================================
RCS file: /home/wine/wine/dlls/shell32/shlfileop.c,v
retrieving revision 1.23
diff -u -r1.23 shlfileop.c
--- dlls/shell32/shlfileop.c	21 Jan 2003 19:36:24 -0000	1.23
+++ dlls/shell32/shlfileop.c	23 Jan 2003 11:03:40 -0000
@@ -129,33 +129,60 @@
 }
 
 /*************************************************************************
- * SHCreateDirectory				[SHELL32.165]
+ * SHCreateDirectory                       [SHELL32.165]
  *
  * NOTES
  *  exported by ordinal
- *  not sure about LPSECURITY_ATTRIBUTES
+ *  WinNT/2000 exports Unicode
  */
-DWORD WINAPI SHCreateDirectory(LPSECURITY_ATTRIBUTES sec,LPCSTR path)
+DWORD WINAPI SHCreateDirectoryAW(HWND hWnd, LPCVOID path)
+{
+	if (SHELL_OsIsUnicode())
+	  return SHCreateDirectoryExW(hWnd, path, NULL);
+	return SHCreateDirectoryExA(hWnd, path, NULL);
+}
+
+/*************************************************************************
+ * SHCreateDirectoryEx                     [SHELL32.@]
+ *
+ * NOTES
+ */
+DWORD WINAPI SHCreateDirectoryExA(HWND hWnd, LPCSTR path, LPSECURITY_ATTRIBUTES sec)
 {
 	DWORD ret;
-	TRACE("(%p,%s)\n",sec,path);
-	if ((ret = CreateDirectoryA(path,sec)))
+	TRACE("(%p, %s, %p)\n",hWnd, path, sec);
+	if ((ret = CreateDirectoryA(path, sec)))
 	{
 	  SHChangeNotify(SHCNE_MKDIR, SHCNF_PATHA, path, NULL);
 	}
+	else if (hWnd)
+	  FIXME("Semi-stub, non zero hWnd should be used as parent for error dialog!");
+	return ret;
+}
+
+DWORD WINAPI SHCreateDirectoryExW(HWND hWnd, LPCWSTR path, LPSECURITY_ATTRIBUTES sec)
+{
+	DWORD ret;
+	TRACE("(%p, %s, %p)\n",hWnd, debugstr_w(path), sec);
+	if ((ret = CreateDirectoryW(path, sec)))
+	{
+	  SHChangeNotify(SHCNE_MKDIR, SHCNF_PATHW, path, NULL);
+	}
+	else if (hWnd)
+	  FIXME("Semi-stub, non zero hWnd should be used as parent for error dialog!");
 	return ret;
 }
 
 /************************************************************************
- *      Win32DeleteFile                         [SHELL32.164]
+ * Win32DeleteFile                         [SHELL32.164]
  *
- * Deletes a file.  Also triggers a change notify if one exists.
+ * Deletes a file. Also triggers a change notify if one exists.
  *
- * FIXME:
- * Verified on Win98 / IE 5 (SHELL32 4.72, March 1999 build) to be ANSI.
- * This is Unicode on NT/2000
+ * NOTES:
+ *  Verified on Win98 / IE 5 (SHELL32 4.72, March 1999 build) to be ANSI.
+ *  This is Unicode on NT/2000
  */
-BOOL WINAPI Win32DeleteFile(LPSTR fName)
+BOOL WINAPI Win32DeleteFileA(LPCSTR fName)
 {
 	TRACE("%p(%s)\n", fName, fName);
 
@@ -164,6 +191,22 @@
 	return TRUE;
 }
 
+BOOL WINAPI Win32DeleteFileW(LPCWSTR fName)
+{
+	TRACE("%p(%s)\n", fName, debugstr_w(fName));
+
+	DeleteFileW(fName);
+	SHChangeNotify(SHCNE_DELETE, SHCNF_PATHW, fName, NULL);
+	return TRUE;
+}
+
+DWORD WINAPI Win32DeleteFileAW(LPCVOID fName)
+{
+	if (SHELL_OsIsUnicode())
+	  return Win32DeleteFileW(fName);
+	return Win32DeleteFileA(fName);
+}
+
 /**************************************************************************
  *	SHELL_FileNamesMatch()
  *
@@ -269,8 +312,8 @@
                     char *fromfile;
                     int lenPTo;
                     if ( ! destisdir) {
-                        TRACE("   creating directory %s\n",pTo);
-                        SHCreateDirectory(NULL,pTo);
+                      TRACE("   creating directory %s\n",pTo);
+                      SHCreateDirectoryExA(NULL, pTo, NULL);
                     }
                     lenPTo = strlen(pTo);
                     while(1) {
@@ -308,7 +351,7 @@
                                           {
                                               SHFILEOPSTRUCTA shfo;
 
-                                              SHCreateDirectory(NULL,pTempTo);
+                                              SHCreateDirectoryExA(NULL, pTempTo, NULL);
                                               PathAddBackslashA(szTempFrom);
                                               strcat(szTempFrom, "*.*");
                                               szTempFrom[strlen(szTempFrom) + 1] = '\0';
@@ -343,7 +386,7 @@
                         pFrom += strlen(pFrom) + 1;
                     }
                 } else {
-                    while(1) {
+                    while (1) {
                             if(!pFrom[0]) break;
                             if(!pTo[0]) break;
                             TRACE("   From='%s' To='%s'\n", pFrom, pTo);
@@ -354,7 +397,7 @@
                                 strcpy( pTempTo, pTo );
                                 PathRemoveFileSpecA(pTempTo);
                                 TRACE("   Creating Directory '%s'\n", pTempTo);
-                                SHCreateDirectory(NULL,pTempTo);
+                                SHCreateDirectoryExA(NULL, pTempTo, NULL);
                                 HeapFree(GetProcessHeap(), 0, pTempTo);
                             }
                             if (lpFileOp->wFunc == FO_COPY)
@@ -480,6 +523,6 @@
 {
 	char root[4];
 	strcpy(root, "A:\\");
-	root[0] += drive;
+	root[0] += (char)drive;
 	return (GetDriveTypeA(root) == DRIVE_REMOTE);
 }

Index: include/shlobj.h
===================================================================
RCS file: /home/wine/wine/include/shlobj.h,v
retrieving revision 1.58
diff -u -r1.58 shlobj.h
--- include/shlobj.h	21 Jan 2003 19:36:24 -0000	1.58
+++ include/shlobj.h	23 Jan 2003 11:06:09 -0000
@@ -498,6 +498,15 @@
 void WINAPI SHChangeNotify(LONG wEventId, UINT uFlags, LPCVOID dwItem1, LPCVOID dwItem2);
 
 /****************************************************************************
+* SHCreateDirectory API
+*/
+DWORD WINAPI SHCreateDirectory(HWND, LPCVOID);
+#define      SHCreateDirectory WINELIB_NAME_AW(SHCreateDirectory)
+
+DWORD WINAPI SHCreateDirectoryExA(HWND, LPCSTR, LPSECURITY_ATTRIBUTES);
+DWORD WINAPI SHCreateDirectoryExW(HWND, LPCWSTR, LPSECURITY_ATTRIBUTES);
+
+/****************************************************************************
 * SHGetSpecialFolderLocation API
 */
 HRESULT WINAPI SHGetSpecialFolderLocation(HWND, INT, LPITEMIDLIST *);

Index: dlls/shell32/shell32.spec
===================================================================
RCS file: /home/wine/wine/dlls/shell32/shell32.spec,v
retrieving revision 1.62
diff -u -r1.62 shell32.spec
--- dlls/shell32/shell32.spec	21 Jan 2003 19:36:24 -0000	1.62
+++ dlls/shell32/shell32.spec	23 Jan 2003 11:19:18 -0000
@@ -151,8 +151,8 @@
  161 stdcall SHRunControlPanel (long long) SHRunControlPanel
  162 stdcall SHSimpleIDListFromPath (ptr) SHSimpleIDListFromPathAW
  163 stdcall StrToOleStr (wstr str) StrToOleStrAW
- 164 stdcall Win32DeleteFile(str) Win32DeleteFile
- 165 stdcall SHCreateDirectory(long long) SHCreateDirectory
+ 164 stdcall Win32DeleteFile(str) Win32DeleteFileAW
+ 165 stdcall SHCreateDirectory(long ptr) SHCreateDirectoryAW
  166 stdcall CallCPLEntry16(long long long long long long) CallCPLEntry16
  167 stdcall SHAddFromPropSheetExtArray(long long long) SHAddFromPropSheetExtArray
  168 stdcall SHCreatePropSheetExtArray(long str long) SHCreatePropSheetExtArray
@@ -355,6 +355,8 @@
 @ stdcall SHBrowseForFolderA(ptr) SHBrowseForFolderA
 @ stdcall SHBrowseForFolderW(ptr) SHBrowseForFolderW
 @ stdcall SHChangeNotify (long long ptr ptr) SHChangeNotify
+@ stdcall SHCreateDirectoryExA(long str ptr) SHCreateDirectoryExA
+@ stdcall SHCreateDirectoryExW(long wstr ptr) SHCreateDirectoryExW
 @ stub ShellHookProc
 @ stub SHEmptyRecycleBinA at 12
 @ stub SHEmptyRecycleBinW at 12




More information about the wine-patches mailing list