1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-23 16:24:02 +00:00

Finder-independent trashPath: method

This commit is contained in:
Eric Petit 2006-03-28 06:26:13 +00:00
parent 5165d09994
commit 280cb54a36

View file

@ -370,21 +370,21 @@
- (void) trashPath: (NSString *) path
{
NSString * string;
NSAppleScript * appleScript;
NSDictionary * error;
string = [NSString stringWithFormat:
@"tell application \"Finder\"\n"
" move (POSIX file \"%@\") to trash\n"
"end tell", path];
appleScript = [[NSAppleScript alloc] initWithSource: string];
if( ![appleScript executeAndReturnError: &error] )
if( ![[NSWorkspace sharedWorkspace] performFileOperation:
NSWorkspaceRecycleOperation source:
[path stringByDeletingLastPathComponent]
destination: @""
files: [NSArray arrayWithObject: [path lastPathComponent]]
tag: nil] )
{
printf( "trashPath failed\n" );
/* We can't move it to the trash, let's try just to delete it
(will work if it is on a remote volume) */
if( ![[NSFileManager defaultManager]
removeFileAtPath: path handler: nil] )
{
printf( "Could not trash `%s'\n", [path UTF8String] );
}
}
[appleScript release];
}
@end