[fpc-pascal] read lines at end of file

johnelee1944 at googlemail.com johnelee1944 at googlemail.com
Tue Apr 12 00:51:17 CEST 2011


So the idea is to open file eg as file of array [1:65536] of char or  
something similar, seek & read to end of file, then go through the last  
array converting to strings by finding crlfs correct? Is this the simplest  
way? If not any outline code?

John

On , José Mejuto <joshyfun at gmail.com> wrote:
> Hello FPC-Pascal,



> Monday, April 11, 2011, 7:55:01 PM, you wrote:



> >> The idea is easy, instead reading forward, you read backwards in

> >> blocks of, say, 64 Kb and count lines back. If not enougth lines you

> >> insert another 64 Kb before and so on. Average line is usually less

> >> than 100 bytes, so each 64 Kb are usually more than 600 lines. Read of

> >> 64 Kb usually takes the same time as read any lower amount when the

> >> block is 4096 bytes aligned.



> MG> You can not really read backwards. You can use

> MG> something like TFileStream.Seek(-4096,soEnd).



> I think that the "read backwards in blocks" already stated that fact,

> but nice annotation.



> --

> Best regards,

> José



> _______________________________________________

> fpc-pascal maillist - fpc-pascal at lists.freepascal.org

> http://lists.freepascal.org/mailman/listinfo/fpc-pascal


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20110411/7cacd35a/attachment.html>


More information about the fpc-pascal mailing list