Re: Issue with read/write to NSFileHandle

2016-06-30 Thread Ken Thomases
On Jun 30, 2016, at 8:17 PM, Graham Cox wrote: > > What still seems a bit unclear is what a file handle “for update” is meant > for, if separate read and write handles are needed. You can use a single file handle for both reading and writing. It's just that you will have to seek around to rea

Re: Issue with read/write to NSFileHandle

2016-06-30 Thread Graham Cox
> On 1 Jul 2016, at 2:18 AM, Jens Alfke 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 a

Re: Issue with read/write to NSFileHandle

2016-06-30 Thread Jens Alfke
> On Jun 29, 2016, at 8:40 PM, Graham Cox > wrote: > > Reading the documentation, NSFileHandle seems to have only one file offset, > which is common to both read and write, which is a bit puzzling, because > surely you’d want to write at the end of the file, but

Re: Issue with read/write to NSFileHandle

2016-06-29 Thread Shane Stanley
On 30 Jun 2016, at 4:33 PM, Graham Cox wrote: > > Yes, is that wrong? > > If it is wrong, what’s the purpose of +[NSFileHandle > fileHandleForUpdatingURL:…] which is intended for read/write, as opposed to > making a separate one for read and another for write? I think it's meant for simple ca

Re: Issue with read/write to NSFileHandle

2016-06-29 Thread Graham Cox
> On 30 Jun 2016, at 2:27 PM, Shane Stanley wrote: > > You're not trying to use the same handle for both, are you? Yes, is that wrong? If it is wrong, what’s the purpose of +[NSFileHandle fileHandleForUpdatingURL:…] which is intended for read/write, as opposed to making a separate one for r

Re: Issue with read/write to NSFileHandle

2016-06-29 Thread Shane Stanley
On 30 Jun 2016, at 1:40 PM, Graham Cox wrote: > > Reading the documentation, NSFileHandle seems to have only one file offset, > which is common to both read and write, which is a bit puzzling, because > surely you’d want to write at the end of the file, but read from wherever > you’d read from

Issue with read/write to NSFileHandle

2016-06-29 Thread Graham Cox
Hi all, I’m not sure whether what I’m doing is right here. I’m trying to implement a simple logging system, where I write to a log file, and a NSTextView shows what’s in the log. I have a NSFileHandle that I create using +[NSFileHande fileHandleForUpdatingAtURL:error:] I write new log message