Reading a structured binary file?

Jonathan M Davis jmdavisProg at gmx.com
Fri Aug 2 15:13:13 PDT 2013


On Friday, August 02, 2013 19:49:54 Gary Willoughby wrote:
> What library commands do i use to read from a structured binary
> file? I want to read the byte stream 1, 2 maybe 4 bytes at a time
> and cast these to bytes, shorts and ints respectively. I can't
> seem to find anything like readByte().

I'd probably use std.mmfile and std.bitmanip to do it. MmFile will allow you to 
efficiently operate on the file as a ubyte[] in memory thanks to mmap, and 
std.bitmanip's peek and read functions make it easy to convert multiple bytes 
into integral values.

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list