Re: Move a file to the Trash
Re: Move a file to the Trash
- Subject: Re: Move a file to the Trash
- From: Clark Mueller <email@hidden>
- Date: Wed, 6 Nov 2002 22:55:26 -0700
What about NSWorkspace? I'm surprised nobody at least suggested this...
Following is a chunk from a class that I use in my app Modifier to do
things with files (
http://www.finikin.com). Most everyone who's ever
asked a question about file attributes on this list has gotten a code
snippet from said class from me. This is what I use, and it hasn't
turned up as a problem, so far as I know... Here's the code:
- (BOOL)trashWithPath:(NSString *)path{
// Moves 'path' to the trash, a la NSWorkspace.
NSWorkspace *ws = [NSWorkspace sharedWorkspace];
if(![ws performFileOperation:NSWorkspaceRecycleOperation
source:[path stringByDeletingLastPathComponent] destination:@""
files:[NSArray arrayWithObject:[path lastPathComponent]] tag:0]){
return NO;
}
else{
[self wakeUpPath:path];
return YES;
}
}
Clark Mueller
email@hidden
http://www.finikin.com/
On Wednesday, November 6, 2002, at 09:55 AM, Olivier wrote:
>
another option would be to script system events
>
(/System/Library/CoreServices/System Events.app) as this is running in
>
the background, launch on start and in the system folder, chances of it
>
not running are smaller (if i remember correctly the finder actually
>
just forward the event to this guy). The only problem with it, i do not
>
know if this app is here to stay or not. I seem to remember some
>
discussion on the applescript mailing list about wether it was safe or
>
not to use the System Events app instead of the Finder.
>
>
Olivier
>
>
>
On Wednesday, November 6, 2002, at 10:18 AM, Ondra Cada wrote:
>
>
> On Wednesday, November 6, 2002, at 04:57 , Marco Binder wrote:
>
>
>
>> I just knew, Ondra would reply to this one! LOL Ondra, you really
>
>> HATE AppleScript, dont you?
>
>
>
> No, actually I like it, but I really HATE stupid code. As such
>
> qualifies, among others, presuming there is an application which in
>
> fact might not be there -- like Apple did in 10.1 with the print
>
> preview, which bug, I haste to add, they have already fixed in 10.2.
>
> ---
>
> Ondra Cada
>
> OCSoftware: email@hidden http://www.ocs.cz
>
> private email@hidden http://www.ocs.cz/oc
>
> _______________________________________________
>
> cocoa-dev mailing list | email@hidden
>
> Help/Unsubscribe/Archives:
>
> http://www.lists.apple.com/mailman/listinfo/cocoa-dev
>
> Do not post admin requests to the list. They will be ignored.
>
_______________________________________________
>
cocoa-dev mailing list | email@hidden
>
Help/Unsubscribe/Archives:
>
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
>
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.