Re: Removing a file via NSFileWrapper
Re: Removing a file via NSFileWrapper
- Subject: Re: Removing a file via NSFileWrapper
- From: Quincey Morris <email@hidden>
- Date: Sun, 30 Mar 2014 17:35:24 -0700
On Mar 30, 2014, at 17:02 , Colas B <email@hidden> wrote:
> With the ‘NSFileWrapperWritingAtomic’ option, the "re-writing" goes well (error = nil). With other options, the "re-writing" does not go well and there is an error ("Error Domain=NSCocoaErrorDomain Code=516 "The file “folderName” couldn’t be saved in the folder “Desktop” because a file with the same name already exists." UserInfo=0x610000069c80 {NSFilePath=/Users/colas/Desktop/folderName, NSUnderlyingError=0x610000041e60 "The operation couldn’t be completed. File exists"}".
I don’t know the answer. It’s not clear from the documentation whether the ‘writeToURL:’ method is supposed re-write an existing folder in place, or whether it’s correct to give the above error. (NSFileWrapper documentation is really lousy.)
It’s possible that it’s not supposed to. In that case, the fact that it does when ‘NSFileWrapperWritingAtomic’ is specified may be accidental. It’s possible that, when the option is *not* specified, you’re supposed to move the old top-level folder somewhere else and do the ‘writeToURL:’ specifying that “somewhere else” as the ‘originalURL’ parameter.
All I can say is that NSFileWrapper does what it does, and its API contract isn’t specific enough to allow us to deduce what it will do in any scenario.
_______________________________________________
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