reading a structure (eg header info) from file

captaindet 2krnk at gmx.net
Thu Jul 4 14:40:25 PDT 2013


thanks everyone for your help!

i should have mentioned that i did play with std.stdio.File.readf
and rawRead but was too thick to figure out a working solution.

o i could not figure out how to make readf work with my self
defined struct

o same with rawRead. but here i understand my mistake now: i have
to pass an array of my struct, even if i only want to read it
once.

endianness and padding are certainly issues. i have spent some
time figuring out how to adjust struct packing in D. my
definitions are now full of align(2) declarations... as for the
endianness, as i can oversee it now all potential users will sit
on little-endian machines. the group of users is small, just our
workgroup.

the datafiles in question are produced by some 3rd party 16bit
windows software, so i have to accept the way the data is stored
in the file. also, they can be as big as 2GB so reading in the
whole file is not an option.

thanks again,

det


More information about the Digitalmars-d-learn mailing list