in reply to Copying binary data efficiently

If all you want to do is change a single byte in a file - rather than copy the file - take a look at seek.

You can use it to move to an arbritary point in a file. You can then just overwrite the byte you want to change rather than copying the whole file.

Replies are listed 'Best First'.
Re: Re: Copying binary data efficiently
by mildside (Friar) on Jul 30, 2003 at 23:44 UTC
    Doh - Of course!! In my job I'm so used to reading text data in one form and writing it out to a new file in a usually entirely different form that it didn't even occur to me to just alter the existing file.

    So I should have opened the file with the "+<" mode for read/write, seek to position 148 and write the byte there. (I would still need to copy the file first as I need to keep the original.)

    Talk about closed thinking - I can't believe I overlooked that. Thanks adrianh and ++ (once I get some more votes!).

    Cheers!