A Simpler Safe-Save Strategy
A Simpler Safe-Save Strategy
When the user saves a changed version of a document, most applications
perform a "safe save"-a sequence of updating, renaming, saving, and deleting
files that preserves the contents of the old file until the new version is safely
recorded. Typically, an application saves the new version of the file under a
temporary name, renames both files, and then discards the original.
Version 7.0 introduces the FSpExchangeFiles and PBExchangeFiles
functions, which simplify a safe save. Both functions exchange the contents of
two files by altering the catalog entries for the files. To save a new version of a
file using file ex change, you save the copy, exchange the contents of the two
files, and discard the newly saved file, which now holds the original version of
the file. See Updating Files under the section,
Using the File Manager,for a description of how to update files with
Updating a file with FSpExchangeFiles preserves the file's ID, which is
used by the Alias Manager. (See File IDs under the section en titled See
New Special-Purpose Features in the File Manager for a description
of file IDs; see the Finder Interface for a description of Finder aliases and
see the section called Alias Manager for a description of the underlying
software.) Although the Alias Manager is usually able to resolve an alias
with an obsolete file ID, you can improve the reliability of aliases by
preserving file IDs on all saves.