File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed
Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -375,6 +375,23 @@ static BOOL Trash(NSString *path) {
375375 tag: NULL ];
376376 }
377377#endif
378+
379+ // As a last resort try trashing with AppleScript
380+ if (!result) {
381+ NSAppleScript *appleScript = [[[NSAppleScript alloc ] initWithSource:
382+ [NSString stringWithFormat: @" \
383+ set theFile to POSIX file \" %@ \" \n \
384+ tell application \" Finder\" \n \
385+ move theFile to trash \n \
386+ end tell" , path]] autorelease ];
387+ NSDictionary *errorDict = nil ;
388+ NSAppleEventDescriptor *scriptResult = [appleScript executeAndReturnError: &errorDict];
389+ if (scriptResult == nil ) {
390+ NSLog (@" Trash AppleScript error: %@ " , errorDict);
391+ }
392+ result = (scriptResult != nil );
393+ }
394+
378395 if (!result) {
379396 NSLog (@" ERROR -- Could not trash '%@ '" , path);
380397 }
You can’t perform that action at this time.
0 commit comments