Re: NSData writeToFile
Re: NSData writeToFile
- Subject: Re: NSData writeToFile
- From: Clark Cox <email@hidden>
- Date: Thu, 23 Dec 2004 19:52:48 -0500
On Thu, 23 Dec 2004 15:38:32 -0800, Chuck Soper <email@hidden> wrote:
> Hello,
>
> I'm using this NSData's method:
> - (BOOL)writeToFile:(NSString *)path atomically:(BOOL)flag
> to write some data to a file on disk. It works great.
>
> If a file with the same name already exists, writeToFile: just
> replaces it. Is this expected behavior? Is this approach okay? Do you
> think that it could break in the future?
This appears to be the intended behavior. Otherwise, the "atomically:"
parameter would be pointless.
>
> Should I see if the file exists and delete if it does with these
> FileManager methods?
> - (BOOL)fileExistsAtPath:(NSString *)path
> - (BOOL)removeFileAtPath:(NSString *)path handler:(id)handler
This would prevent your write from being atomic (what happens if the
remove succeeds, but some error happens during the write; you've then
got a potentially partially written file).
--
Clark S. Cox III
email@hidden
http://www.livejournal.com/users/clarkcox3/
http://homepage.mac.com/clarkcox3/
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden