At 2:45 PM -0400 8/30/02, Charles Yeomans wrote:
It would be safer to write the new file to a temporary file, then
swap the contents of the two files. There are MacOS File Manager
functions that you can use to do this. I assume that the Windows
API supports this sort of operation as well.
Though not quite as good as swapping the file contents, there's
another method that's almost and good but more portable. Write out
your new file to the same folder but with a temporary file name (just
make up one that doesn't already exist). Then, when that's done
successfully, rename the old file to a different temporary name, name
your new file to its proper name, and delete the old file.
In any case, the idea is to put off deleting the old file as long as
possible, so that if you crash (lose power, etc.) in the middle of
saving, the user's data isn't lost.
Cheers,
- Joe
--
,------------------------------------------------------------------.
| Joseph J. Strout REAL Software, Inc. |
| joe at realsoftware dot com http://www.realsoftware.com |
`------------------------------------------------------------------'
|