BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

FileRead and FileSeek

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Students)
View previous topic :: View next topic  
Author Message
DavideP
Guest





PostPosted: Mon Apr 02, 2007 7:55 pm    Post subject: FileRead and FileSeek Reply with quote



Hi, everybody.
I've a tricky question.

How can read fastly and cleverly the *last* line of a file, using
FileRead and FileSeek functions?

Alternatively, there is a fast and smart method?

Thanks in advance.

Davide
Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Mon Apr 02, 2007 9:37 pm    Post subject: Re: FileRead and FileSeek Reply with quote



"DavideP" <no.spam (AT) here (DOT) plz> wrote in message
news:4611197e$1 (AT) newsgroups (DOT) borland.com...

Quote:
How can read fastly and cleverly the *last* line of a file,
using FileRead and FileSeek functions?

Unless the file has fixed-length lines that are all the same length,
then there is no direct way to determine where the last line is
located. You would have to scan through the file forwards from start
to end until you find the last linebreak, or scan backwards until you
find the first line break.


Gambit
Back to top
Ed Mulroy
Guest





PostPosted: Mon Apr 02, 2007 11:23 pm    Post subject: Re: FileRead and FileSeek Reply with quote



At times in the past I have had to do that. I used a technique similar to
what Remy Lebeau told you. I seeked to the end of the file -2048, read a
2048 byte buffer, searched back from the end to find the end of the line
character (the ending '.', '?' '!') or the last alpha-numeric (some people
omit the punctuation on the last line of a paragraph). I then seeked back
to find the end of line character before that. The start of the last line
is then the first non-blank character going forward from that second end of
line.

.. Ed

Quote:
DavideP wrote in message
news:4611197e$1 (AT) newsgroups (DOT) borland.com...
Hi, everybody.
I've a tricky question.

How can read fastly and cleverly the *last* line of a file, using FileRead
and FileSeek functions?

Alternatively, there is a fast and smart method?
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Students) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.