I have a C-like struct like this:
SomeStruct << BinData::Record
endian :little
uint32 :offsetOfName
uint32 :offsetOfLastname
#...
uint32 :lenVars
struct :Person, :length => :lenVars
string :name
string :lname
#...
end
I have a bunch of offsets and lengths before :Person. All the offsets and lengths describe the data within the :Person struct.
How can I start reading data at a specified offset, for the given length, or until the next offset?
Seek to offset 1234 and then read 32 bytes into String
s:Update: It looks like BinData understands records that encode the lengths of their own fields, but I doubt if there is any way to make it seek for you, unless you are willing to essentially encode dummy fields the size of the seeked-over space, and then ignore forever the data that it’s skipping.
I suspect that a good solution will involve an explicit seek and then
someBinDataObject.read(f)to get the record.