diff --git a/src/ios.h b/src/ios.h index 50767c5b7..991a41310 100644 --- a/src/ios.h +++ b/src/ios.h @@ -29,6 +29,7 @@ const char *apple_fontsPath(void); const char *apple_preferencesPath(void); const char *apple_globalPreferencesPath(void); const char *apple_picturesPath(void); +int apple_trash(const char *path); #endif /* __IOS_H__ */ diff --git a/src/ios.m b/src/ios.m index 4754f3c17..58f75877a 100644 --- a/src/ios.m +++ b/src/ios.m @@ -20,6 +20,7 @@ (See COPYING.txt) */ #include +#include #include #include #include @@ -86,3 +87,9 @@ const char *apple_picturesPath(void) { return IOS_PICTURES_PATH; } + + +int apple_trash(const char *path) +{ + return unlink(path); +} diff --git a/src/macos.h b/src/macos.h index bbd8615fc..fe610cb19 100644 --- a/src/macos.h +++ b/src/macos.h @@ -32,6 +32,7 @@ const char *apple_fontsPath(void); const char *apple_preferencesPath(void); const char *apple_globalPreferencesPath(void); const char *apple_picturesPath(void); +int apple_trash(const char *path); #endif /* __MACOS_H__ */ diff --git a/src/macos.m b/src/macos.m index 235df821c..1b0460ac4 100644 --- a/src/macos.m +++ b/src/macos.m @@ -221,3 +221,19 @@ const char *apple_picturesPath(void) return p; } + +int apple_trash(const char *path) +{ + NSFileManager *manager = [NSFileManager defaultManager]; + NSURL *url = [NSURL fileURLWithPath:[NSString stringWithUTF8String:path]]; + NSURL *trash = nil; + NSError *error = nil; + + [manager trashItemAtURL:url resultingItemURL:&trash error:&error]; + if(error) { + DEBUG_PRINTF("%s\n", [[error localizedDescription] UTF8String]); + return -1; + } + + return 0; +} diff --git a/src/tuxpaint.c b/src/tuxpaint.c index 0ce372eb1..a7948c7da 100644 --- a/src/tuxpaint.c +++ b/src/tuxpaint.c @@ -28056,11 +28056,12 @@ int main(int argc, char *argv[]) */ static int trash(char *path) { -#ifdef UNLINK_ONLY +#if defined(UNLINK_ONLY) return (unlink(path)); -#else -#ifdef WIN32 +#elif defined(WIN32) return win32_trash(path); +#elif defined(__APPLE__) + return apple_trash(path); #else char fname[MAX_PATH], trashpath[MAX_PATH], dest[MAX_PATH], infoname[MAX_PATH], bname[MAX_PATH], ext[MAX_PATH]; char deldate[32]; @@ -28220,13 +28221,10 @@ static int trash(char *path) /* FIXME: xcfe and elsewhere: Anything to do? */ - /* FIXME: Mac OS X */ - /* FIXME: Haiku */ return (0); -#endif /* WIN32 */ -#endif /* UNLINK_ONLY */ +#endif } /**