HOW to read particular bytes from a large file effeciently?

change2718_at_yahoo.com
Date: 12/27/04


Date: 26 Dec 2004 16:09:08 -0800

Hi all
I have a very large file (50-150 MB)
I need to read a particular bytes...
it's not always a text file

anyway when it's a binary file
and i need to read , say , that last 1000 characters
or sometimes, say, from the byte 5,000,000th to the byte 5,000,999th
into a byte array or char[] buffer or another small
"sub-file"
resulted resulted from the big one?! I'm trying
to do all that with delphi (and windows API if needed)

so, ..in a fast and effiecient way how could I get
a "random-access" way to read "raw binary" quickly and effieciently
without performance drawbacks or huge resources/CPU-overhead
consumption?

I faced a situation with reading lines from a a small text file
i can use tstrings.loadfromfile(), but it's not the mechanism
I'm looking for here, as you see,
and I might use some stream types and use some
procedure /functiom like "Seek" with the stream,
but what to do when it's large file and it makes it more challenging,
that's it's not always text file!

I want to consume as least RAM as possible, with the least cpu
cycles,...
please tell my your thoughts even if it's not a perfect solution!

should I make a dll in C++ (my final resort) that export the needed
functions?
or are there ready and easier things in Delphi or Windows
API that I can use?
thank you so much for consideration!

thank you very much in advance!