At 11:53 AM -0700 8/30/02, Joseph J. Strout wrote:
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.
It seems to me that this suggestion, and the idea of deleting the
file and writing a new one, would both result in a file with a new
creation date which could be confusing to the user. Swapping with a
temporary file using the Toolbox call has the advantage of changing
only the file's modification date as far as I know.
---
A searchable archive of this list is available at:
<http://dbserver.realsoftware.com/KBDB/search.php>
Unsubscribe:
<mailto:realbasic-nug-off at lists dot realsoftware dot com>
Subscribe to the digest:
<mailto:realbasic-nug-digest at lists dot realsoftware dot com>
.
|