Re: Reading from the "almost end" of a file
Re: Reading from the "almost end" of a file
- Subject: Re: Reading from the "almost end" of a file
- From: Public Look <email@hidden>
- Date: Tue, 17 Feb 2004 17:02:06 -0500
Why not just use popen() and the tail program ?
On Feb 17, 2004, at 4:09 AM, Yann Bizeul wrote:
Hi list,
I would like to use NSFileHandle to reproduce the behavior of tail in
terminal.
As seen in the list, what I did and is working is opening the file,
and set a 10ms NSTimer to get availableData on the NSFileHandle. That's
perfect, and not CPU intensive as I thought.
Actually, I do this :
fh = [ NSFileHandle fileHandleForReadingAtPath: [ self file ]];
int offset = [ fh seekToEndOfFile ];
[ fh closeFile ];
fh = [[ NSFileHandle fileHandleForReadingAtPath: [ self file ]]
retain ];
offset = (offset - 2000);
if (offset < 0) offset=0;
[ fh seekToFileOffset: offset];
But it does not seek to the 2000th byte before the end but directly to
the end of the file.
What's the good way to do this, is there a quick way to say "from 10th
*line* of the file before the end"
Thank you
--
Yann Bizeul - yann at tynsoe.org
http://projects.tynsoe.org/
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.