[Newbies] Reading and writing C structs

David Finlayson dfinlayson at usgs.gov
Fri May 23 21:10:58 UTC 2008


An instrument I am working with creates a complicated binary file
(memory dumps of C structs). I would like to try reading the file into
Squeak for a cool new project. What's the best way to set up and read
C-based structs and then, once I'm done, to write them back out again
(including endianness, padding bytes and all the other nonsense)? I
could use pointers to related classes as well if they are
needed/useful for working with primitive types like this. An example
would be great.

I found that there are some interesting methods in PositionableStream
for reading and writing integer types from a binary stream. Is this
where I should start? What about floats and doubles? This seems a bit
low-level, but I could work with it. I'm a so-so C programmer with
experience in Python, but still learning Smalltalk.

David


More information about the Beginners mailing list