From cd454fdc2ed6c4a8b432dd4617fb61949c786087 Mon Sep 17 00:00:00 2001 From: Ken Thomases Date: Wed, 14 Mar 2012 16:49:47 -0500 Subject: [PATCH] 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 3c4c966f318..d28b52a1dd8 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 023e46e42ac..a0e785b681b 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 cf61e432538..ef2d7344465 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 c2e4ab21af9..a5d53a19b76 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 +#undef GetCurrentThread +#undef LoadResource +#undef DPRINTF +#endif + #include +#include +#include +#include +#include #ifdef HAVE_SYS_STAT_H # include #endif @@ -41,17 +54,78 @@ #include "winreg.h" #include "shlwapi.h" #include "winternl.h" - -#include -#include -#include -#include #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 c26def2278a..0332f69251a 100644 --- a/include/config.h.in +++ b/include/config.h.in @@ -61,6 +61,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_COREAUDIO_COREAUDIO_H +/* Define to 1 if you have the header file. */ +#undef HAVE_CORESERVICES_CORESERVICES_H + /* Define to 1 if you have the header file. */ #undef HAVE_CUPS_CUPS_H -- 2.11.4.GIT