The normal way of avoiding the “delete then move fails problem” is:
- Write to file.new
- Move file.current to file.old
- Move file.new to file.current
- Delete file.new
Then when you come to read, use file.new if file.current is missing, deleting file.old if you see it.
Checking for whether or not the file is available: try opening it for write, but appending to the end. Of course, you’ll need to close the handle before you then move it, and in-between someone else could open it – but it would at least be a reasonable optimisation.
Not sure about copying summaries etc, I’m afraid.