• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Reading from the "almost end" of a file
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Reading from the "almost end" of a file


  • Subject: Re: Reading from the "almost end" of a file
  • From: Yann Bizeul <email@hidden>
  • Date: Wed, 18 Feb 2004 08:03:23 +0100

Why not just use popen() and the tail program ?
Because :
1/ I don't want to spread tail processes on the machine
2/ Tail thinks it is smart enough to drop special chars like \r, or \t, or anything else that is not alphanumeric, but I don't want it to !

Thanks

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.




--
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.

References: 
 >Reading from the "almost end" of a file (From: Yann Bizeul <email@hidden>)
 >Re: Reading from the "almost end" of a file (From: Public Look <email@hidden>)

  • Prev by Date: launching browser from NSText Field
  • Next by Date: Re: What type of view for a simple editable list?
  • Previous by thread: Re: Reading from the "almost end" of a file
  • Next by thread: Knob Resize Problem
  • Index(es):
    • Date
    • Thread