The Finder does its special sauce when you use the shortcut, and NSWorkspace
(which we use to perform the "Move to trash" step) doesn't. AFAIK there's no
public way of making that work, short of reimplementing the whole "Move to
trash" thing, reverse-engineering what/where/how Finder stores its Put Back
info, and just making it Work Right™ w.r.t to duplicates, external volumes and
other nice, fiddly things.
The best is to file a radar.
Note that here, neither the AppleScript method, nor the bash method you've
pointed out since work. Make sure that you're trying with something you've not
already "Move to trash"ed because it seems it's easy to make Finder lose track
of which file came from where, so "Put back" doesn't actually Put back the
*real*original file (I've just been bitten by that while doing a quick
NSWorkspace check).
Test code, which doesn't enable Put back, in case you're curious...
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
NSError *error = nil;
NSURL *fileURL = [[NSURL fileURLWithPath:@"~/testfile"]
URLByStandardizingPath];
NSAssert(fileURL != nil, @"fileURL is nil");
if (![[NSFileManager defaultManager] createDirectoryAtURL:[fileURL
URLByDeletingLastPathComponent] withIntermediateDirectories:YES attributes:nil
error:&error]) {
[NSApp presentError:error];
[NSApp terminate:self];
}
if (![@"testFile" writeToURL:fileURL atomically:YES
encoding:NSUTF8StringEncoding error:&error]) {
[NSApp presentError:error];
[NSApp terminate:self];
}
[[NSWorkspace sharedWorkspace] recycleURLs:@[fileURL]
completionHandler:^(NSDictionary *newURLs, NSError *error) {
NSLog(@"%@ => %@", newURLs, error);
}];
}
Cordialement,
Etienne Samson
--
[email protected]
> Le 18 mai 2015 à 13:26, Rob McBroom <[email protected]> a écrit :
>
> True. Much ink has been spilled talking about that (by other devs), but I
> don’t know what the exact issue is.
>
> --
> Rob McBroom
> http://www.skurfer.com/
>
> --
> You received this message because you are subscribed to the Google Groups
> "Quicksilver" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/blacktree-quicksilver.
> For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups
"Quicksilver" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/blacktree-quicksilver.
For more options, visit https://groups.google.com/d/optout.