I need to edit a binary file but I need to have some understanding of the gothcas so the edited info can get put back in correctly. I am editing with OSX but the format is little endian x86. Any one have any hints to make this a bit less painful?
Shouldn't be any big issues. On windows, you need to make sure to set binmode() on the filehandle, but I doubt OSX has that issue.
I'd probably suggest using sysread and syswrite instead of <>/read/print. sys* are unbuffered and don't mix well with the other i/o functions. I find it more straightforward to use them and fill my own buffers when working with binary files.
Get real familliar with pack/unpack. Knowing how to use them well will make your life much easier. It sounds like you already understand byte-ordering, so you'll probably do fine.
I am trying to become more chummy with pack/unpack. The data structure is quite complex and trying to decide the "easiest way" isn't always the best way. Thanks for comment.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.