Classic MacOS-9 had the PBExchangeFiles call which did this perfectly. Before call:
dirEntryA -> fileContentsA
dirEntryB -> fileContentsB
after call dirEntryA -> fileContentsB
dirEntryB -> fileContentsA
This meant that the user kept all meta info for files, e.g. tags, window position, custom icons, etc.So when saving a new document you wrote it to a new hidden temp file, and when everything was written, you called PBExchangeFiles to swap the contents of the old and new files. After this you deleted your temp file which now contained the old document content.
http://mirror.informatimago.com/next/developer.apple.com/doc...