Re: Can't set offset of a file NSOutputStream with appending enabled
Re: Can't set offset of a file NSOutputStream with appending enabled
- Subject: Re: Can't set offset of a file NSOutputStream with appending enabled
- From: Ken Thomases <email@hidden>
- Date: Sat, 08 Jun 2013 09:41:53 -0500
On Jun 4, 2013, at 12:32 PM, Hank Bao wrote:
> I tried to set the offset property of a file NSOutputStream by NSStreamFileCurrentOffsetKey with appending enabled with code listed below.
Appending isn't "enabled", per se, it's a mode for the underlying file descriptor that forces data to always be appended to the end of the file. See the open() system call and O_APPEND for the low-level equivalent.
What you're looking for is opening for writing without truncating. It doesn't seem as though NSOutputStream supports that. You may want to look into NSFileHandle instead.
> The document says that NSStreamFileCurrentOffsetKey allows me to manipulate the current read or write position in file-based streams.
That probably means that you can seek within a write stream for a file opened and truncated (after you've written some data, of course).
Regards,
Ken
_______________________________________________
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