Re: Reading a binary file

new topic     » goto parent     » topic index » view thread      » older message » newer message

On Wed, 16 Aug 2000, you wrote:
> In the example for 'get_bytes', it shows how to read a binary file 100
> bytes at a time and when then length of the returned sequence is less than
> 100, the end of the file has been reached:
>
> while 1 do
>     chunk = get_bytes(fn, 100) -- read 100 bytes at a time
>     whole_file &= chunk        -- chunk might be empty, that's ok
>     if length(chunk) < 100 then
>         exit
>     end if
> end while
>
> Is there an easier/faster way to read in a binary file to a sequence in one
> shot?

The number (100) can be anything you want - 1000 or 50000, whatever.
When length(chunk) < that number, you've finished.
Probably the most efficient number would match the size of the input buffer (?)

Irv

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu