Re: Best way to move a file out of the way?
Re: Best way to move a file out of the way?
- Subject: Re: Best way to move a file out of the way?
- From: Daryle Walker <email@hidden>
- Date: Mon, 30 Mar 2015 01:51:32 -0400
> On Mar 24, 2015, at 9:46 PM, Marco S Hyman <email@hidden> wrote:
>
>> If renaming is the answer, is there any sample code to do this safely, taking care of all cases? (For example, replacement name already taken, or adding an extension if the file doesn’t start with one, etc.)
>
> An idea... move the destination file, if it exists, to the trash.
> See NSFileManager's trashItemAtURL:resultingItemURL:error: to do that in a
> safe manner. Trash the old file then save the new.
That was one of my suggestions. Sometimes, when I trash something when a long trash-emptying is already happening, a warning alert appears that says the newly trashed file will be directly deleted instead. I wonder if that alert still gets displayed when the trashing is programmatically instigated. That would be a surprise to the user since my program is a command-line tool (which may be called from a script someday).
—
Daryle Walker
Mac, Internet, and Video Game Junkie
darylew AT mac DOT com
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden