Re: Issue with read/write to NSFileHandle
Re: Issue with read/write to NSFileHandle
- Subject: Re: Issue with read/write to NSFileHandle
- From: Graham Cox <email@hidden>
- Date: Fri, 01 Jul 2016 11:17:57 +1000
> On 1 Jul 2016, at 2:18 AM, Jens Alfke <email@hidden> wrote:
>
> NSFileHandle is just exposing the semantics of a file stream, i.e. a standard C `FILE*`, or a Unix file-descriptor. Every file I/O API I can think of, on any platform, has this behavior — there is a single offset that’s used for reads and writes. It may not make sense to you, but it’s been that way since at least 1969 :)
>
> So yeah, you’ll need two handles, one to write and one to read.
Fair enough, though probably one to write is sufficient in this case - I can pass the text also directly to my text view, so it has the same content, it just then disallows something else to write to the same file and have it show up in the text view, but that is a theoretical benefit anyway - I don’t have a use-case for it right now.
What still seems a bit unclear is what a file handle “for update” is meant for, if separate read and write handles are needed.
> But I have doubts that the readabilityHandler is going to work — I don’t know if it will actually detect that the EOF on the file has advanced. This kind of handler is intended for non-seekable streams like sockets or pipes.
OK, understood.
>
> If I were going to implement a custom logging console, I’d write to a “.log” file and have Console.app open the file, since it’s quite good at displaying logs and updating them in real time.
>
Well, it’s not really a full technical log file - it’s just something that allows a user to see the history of a very small set of particular events (think “activity” rather than a true log). These are not the sorts of users who are going to like being forced to use Console.app
—Graham
_______________________________________________
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