macOS: move deleted file to Trash
As opposed to permanently deleting it. As requested: https://sourceforge.net/p/tuxpaint/feature-requests/148/
This commit is contained in:
parent
d289d407ad
commit
ed885f887d
5 changed files with 30 additions and 7 deletions
16
src/macos.m
16
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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue