links to this page:    
View this PageEdit this PageUploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide
Dealing with binary files
Last updated at 7:44 am UTC on 13 December 2004
To read and write data in binary files, you should first make sure that your file is opened in binary mode:
file := (FileStream fileNamed: 'filename.ext') binary

Actually, that was a lie. The first thing that you need to make sure is that you understand the structure of your binary file. That is, you should know how the data in the file is laid out, what byte ordering numbers have, how strings are encoded etc.
Once you know that, you can just read structures into appropriately-sized byte arrays and use the methods from protocols "platform independent access" and "*FFI" to retrieve your data, or you can use the method from "nonhomogeneous accessing" in class PositionableStream (which is an ancestore to FileStream.