[sac-dev] byte order and swapping
Brian Savage
savage13 at dtm.ciw.edu
Sat Nov 19 13:20:48 PST 2005
I have done a bit of thinking about the byte-order situation and problem
with using write header. I can confirm that using read header and write
header on a sac file in the opposite byte order does not work and
basically destroys the sac file. My thought for fixing this bug is as
follows:
On read:
Add a variable which tracks if the file needed to be swapped on read or
read header.
On write header:
if file not swapped on read:
write header
if file was swapped on read:
swap header and write
On write:
if file not swapped on read:
write header and data
if file was swapped on read:
swap header and data then write
The above tries to keep code in the same byte order it was read in as.
Any thoughts ?
This of course could be extended to include a preferred byte order per
user (LittleEndian/BigEndian or Linux/Sun/Mac/Automatic). However, this
would most likely require that doing a read header/write header sequence
on a swapped byte order file would mean that the data would need to be
read in, swapped, and written out.
Cheers,
Brian
More information about the sac-dev
mailing list