in reply to Re^3: Edit Macintosh file, keeping resource fork
in thread Edit Macintosh file, keeping resource fork

Hmmm ... doesn't quite fit my situation. My edits will probably change the length of the lines, and the files are too big to load all at once.

Is it possible for me to

  1. Open the file for in-place edits
  2. Open a temp file for output
  3. Read the file a line at a time, writing the edited output to the temp file
  4. Close the temp file and open it for read
  5. Read the temp file line by line, writing back to the original file (which is still open for in-place edits)
???

Do I need to do something to truncate the original file before writing back to it, like setting its length to zero or something?

  • Comment on Re^4: Edit Macintosh file, keeping resource fork

Replies are listed 'Best First'.
Re^5: Edit Macintosh file, keeping resource fork
by eieio (Pilgrim) on Feb 11, 2005 at 14:25 UTC
    I made this more complicated than it needs to be. On my Mac OS X system, if I open the file for reading, incrementally read the file and store the modified contents, close the file, reopen the file for writiing, and write the modfiied contents, the resource fork is preserved. I suppose you'll only run into trouble if you create a new file or copy the existing file in such a manner that the resource fork is lost.
      cool, thanks!