Ken Thomases : shell32: Partially implement Mac Trash backing for the Recycle Bin.

Alexandre Julliard julliard at winehq.org
Fri Mar 16 11:27:49 CDT 2012


Module: wine
Branch: master
Commit: cd454fdc2ed6c4a8b432dd4617fb61949c786087
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=cd454fdc2ed6c4a8b432dd4617fb61949c786087

Author: Ken Thomases <ken at codeweavers.com>
Date:   Wed Mar 14 16:49:47 2012 -0500

shell32: Partially implement Mac Trash backing for the Recycle Bin.

---

 configure                |    4 ++
 configure.ac             |    2 +
 dlls/shell32/Makefile.in |    1 +
 dlls/shell32/trash.c     |   86 +++++++++++++++++++++++++++++++++++++++++++---
 include/config.h.in      |    3 ++
 5 files changed, 91 insertions(+), 5 deletions(-)

diff --git a/configure b/configure
index 3c4c966..d28b52a 100755
--- a/configure
+++ b/configure
@@ -666,6 +666,7 @@ COREAUDIO
 SECURITYLIB
 DISKARBITRATIONLIB
 LDEXECFLAGS
+CORESERVICESLIB
 APPLICATIONSERVICESLIB
 IOKITLIB
 COREFOUNDATIONLIB
@@ -5752,6 +5753,7 @@ for ac_header in \
 	CL/cl.h \
 	Carbon/Carbon.h \
 	CoreAudio/CoreAudio.h \
+	CoreServices/CoreServices.h \
 	DiskArbitration/DiskArbitration.h \
 	IOKit/IOKitLib.h \
 	IOKit/hid/IOHIDLib.h \
@@ -6495,6 +6497,8 @@ fi
 
     APPLICATIONSERVICESLIB="-framework ApplicationServices"
 
+    CORESERVICESLIB="-framework CoreServices"
+
     case $host_os in
       darwin11*)
         LDEXECFLAGS="-image_base 0x7bf00000 -Wl,-macosx_version_min,10.6,-segaddr,WINE_DOS,0x00001000,-segaddr,WINE_SHAREDHEAP,0x7f000000"
diff --git a/configure.ac b/configure.ac
index 023e46e..a0e785b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -392,6 +392,7 @@ AC_CHECK_HEADERS(\
 	CL/cl.h \
 	Carbon/Carbon.h \
 	CoreAudio/CoreAudio.h \
+	CoreServices/CoreServices.h \
 	DiskArbitration/DiskArbitration.h \
 	IOKit/IOKitLib.h \
 	IOKit/hid/IOHIDLib.h \
@@ -714,6 +715,7 @@ case $host_os in
     AC_SUBST(COREFOUNDATIONLIB,"-framework CoreFoundation")
     AC_SUBST(IOKITLIB,"-framework IOKit -framework CoreFoundation")
     AC_SUBST(APPLICATIONSERVICESLIB,"-framework ApplicationServices")
+    AC_SUBST(CORESERVICESLIB,"-framework CoreServices")
     case $host_os in
       darwin11*)
         AC_SUBST(LDEXECFLAGS,["-image_base 0x7bf00000 -Wl,-macosx_version_min,10.6,-segaddr,WINE_DOS,0x00001000,-segaddr,WINE_SHAREDHEAP,0x7f000000"]) ;;
diff --git a/dlls/shell32/Makefile.in b/dlls/shell32/Makefile.in
index cf61e43..ef2d734 100644
--- a/dlls/shell32/Makefile.in
+++ b/dlls/shell32/Makefile.in
@@ -3,6 +3,7 @@ MODULE    = shell32.dll
 IMPORTLIB = shell32
 IMPORTS   = uuid shlwapi comctl32 user32 gdi32 advapi32
 DELAYIMPORTS = ole32 oleaut32 shdocvw version
+EXTRALIBS = @CORESERVICESLIB@
 
 C_SRCS = \
 	appbar.c \
diff --git a/dlls/shell32/trash.c b/dlls/shell32/trash.c
index c2e4ab2..a5d53a1 100644
--- a/dlls/shell32/trash.c
+++ b/dlls/shell32/trash.c
@@ -22,7 +22,20 @@
 
 #include "config.h"
 
+#ifdef HAVE_CORESERVICES_CORESERVICES_H
+#define GetCurrentThread MacGetCurrentThread
+#define LoadResource MacLoadResource
+#include <CoreServices/CoreServices.h>
+#undef GetCurrentThread
+#undef LoadResource
+#undef DPRINTF
+#endif
+
 #include <stdarg.h>
+#include <stdio.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <time.h>
 #ifdef HAVE_SYS_STAT_H
 # include <sys/stat.h>
 #endif
@@ -41,17 +54,78 @@
 #include "winreg.h"
 #include "shlwapi.h"
 #include "winternl.h"
-
-#include <stdio.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <time.h>
 #include "wine/debug.h"
 #include "shell32_main.h"
 #include "xdg.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(trash);
 
+#ifdef HAVE_CORESERVICES_CORESERVICES_H
+
+BOOL TRASH_CanTrashFile(LPCWSTR wszPath)
+{
+    char *unix_path;
+    OSStatus status;
+    FSRef ref;
+    FSCatalogInfo catalogInfo;
+
+    TRACE("(%s)\n", debugstr_w(wszPath));
+    if (!(unix_path = wine_get_unix_file_name(wszPath)))
+        return FALSE;
+
+    status = FSPathMakeRef((UInt8*)unix_path, &ref, NULL);
+    HeapFree(GetProcessHeap(), 0, unix_path);
+    if (status == noErr)
+        status = FSGetCatalogInfo(&ref, kFSCatInfoVolume, &catalogInfo, NULL,
+                                  NULL, NULL);
+    if (status == noErr)
+        status = FSFindFolder(catalogInfo.volume, kTrashFolderType,
+                              kCreateFolder, &ref);
+
+    return (status == noErr);
+}
+
+BOOL TRASH_TrashFile(LPCWSTR wszPath)
+{
+    char *unix_path;
+    OSStatus status;
+
+    TRACE("(%s)\n", debugstr_w(wszPath));
+    if (!(unix_path = wine_get_unix_file_name(wszPath)))
+        return FALSE;
+
+    status = FSPathMoveObjectToTrashSync(unix_path, NULL, kFSFileOperationSkipPreflight);
+
+    HeapFree(GetProcessHeap(), 0, unix_path);
+    return (status == noErr);
+}
+
+HRESULT TRASH_EnumItems(LPITEMIDLIST **pidls, int *count)
+{
+    FIXME("stub!\n");
+    return E_NOTIMPL;
+}
+
+HRESULT TRASH_UnpackItemID(LPCSHITEMID id, WIN32_FIND_DATAW *data)
+{
+    FIXME("stub!\n");
+    return E_NOTIMPL;
+}
+
+HRESULT TRASH_RestoreItem(LPCITEMIDLIST pidl)
+{
+    FIXME("stub!\n");
+    return E_NOTIMPL;
+}
+
+HRESULT TRASH_EraseItem(LPCITEMIDLIST pidl)
+{
+    FIXME("stub!\n");
+    return E_NOTIMPL;
+}
+
+#else /* HAVE_CORESERVICES_CORESERVICES_H */
+
 static CRITICAL_SECTION TRASH_Creating;
 static CRITICAL_SECTION_DEBUG TRASH_Creating_Debug =
 {
@@ -603,3 +677,5 @@ HRESULT TRASH_EraseItem(LPCITEMIDLIST pidl)
     SHFree(file_path);
     return S_OK;
 }
+
+#endif /* HAVE_CORESERVICES_CORESERVICES_H */
diff --git a/include/config.h.in b/include/config.h.in
index c26def2..0332f69 100644
--- a/include/config.h.in
+++ b/include/config.h.in
@@ -61,6 +61,9 @@
 /* Define to 1 if you have the <CoreAudio/CoreAudio.h> header file. */
 #undef HAVE_COREAUDIO_COREAUDIO_H
 
+/* Define to 1 if you have the <CoreServices/CoreServices.h> header file. */
+#undef HAVE_CORESERVICES_CORESERVICES_H
+
 /* Define to 1 if you have the <cups/cups.h> header file. */
 #undef HAVE_CUPS_CUPS_H
 




More information about the wine-cvs mailing list