Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

reading binary files

Status
Not open for further replies.

arcnon

Programmer
Aug 12, 2003
242
US
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?

thanks
arcnon
 
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.

Best of luck.

________________________________________
Andrew
 
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.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top