4 ms·
> Unit files. ... you create a new file, which replaces the old one on close. Classic MacOS-9 had the PBExchangeFiles call which did this perfectly. Before ca
by silvestrov 7y ago
> Unit files. ... you create a new file, which replaces the old one on close.
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/documentation/mac/Files/Files-254.html http://mirror.informatimago.com/next/developer.apple.com/doc...
- TeMPOraL 7y agoCommon Lisp standard also strongly suggests this behavior for the :if-exist :supersede argument to #'open: "The existing file is superseded; that is, a new file with the same name as the old one is created. If possible, the implementation should not destroy the old file until the new stream is closed." http://clhs.lisp.se/Body/f_open.htm http://clhs.lisp.se/Body/f_open.htm I imagine they lifted this idea from some prior Lisps, which suggests it's a pretty old concept.
- tobias3 7y agoLike renameat2 on Linux with RENAME_EXCHANGE ?
- silvestrov 7y agoNo renameat2 moves the meta info (e.g. xattrs)as it’s an atomic “mv a temp; mv b a; mv tmp b” So tags from a will end up on b. If b is a temp file, then the tags will be lost after the temp file is deleted.