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:
parent
5165d09994
commit
280cb54a36
1 changed files with 13 additions and 13 deletions
|
@ -370,21 +370,21 @@
|
||||||
|
|
||||||
- (void) trashPath: (NSString *) path
|
- (void) trashPath: (NSString *) path
|
||||||
{
|
{
|
||||||
NSString * string;
|
if( ![[NSWorkspace sharedWorkspace] performFileOperation:
|
||||||
NSAppleScript * appleScript;
|
NSWorkspaceRecycleOperation source:
|
||||||
NSDictionary * error;
|
[path stringByDeletingLastPathComponent]
|
||||||
|
destination: @""
|
||||||
string = [NSString stringWithFormat:
|
files: [NSArray arrayWithObject: [path lastPathComponent]]
|
||||||
@"tell application \"Finder\"\n"
|
tag: nil] )
|
||||||
" move (POSIX file \"%@\") to trash\n"
|
|
||||||
"end tell", path];
|
|
||||||
|
|
||||||
appleScript = [[NSAppleScript alloc] initWithSource: string];
|
|
||||||
if( ![appleScript executeAndReturnError: &error] )
|
|
||||||
{
|
{
|
||||||
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
|
@end
|
||||||
|
|
Loading…
Reference in a new issue