realbasic-nug
[Top] [All Lists]

Re: Should I Delete to Overwrite?

To: REALbasic Network Users Group <realbasic-nug at lists dot realsoftware dot com>
Subject: Re: Should I Delete to Overwrite?
From: Charles Yeomans <yeomans at desuetude dot com>
Date: Fri, 30 Aug 2002 14:45:39 -0400

On Friday, August 30, 2002, at 12:15  PM, Steve Schacht wrote:

Let's say I have a valid reference to a FolderItem for a document that's
currently being edited by a user.  This document has already been saved
previously. So then the user makes some changes, and the dirty flag is set. Now the user selects "Save". When I save the document, I'm writing out the entire file (as a text stream) each time. My question is... Should I be
deleting the existing file before saving?  My testing has indicated that
this is not necessary - i.e. that I can just re-open the text stream and
overwrite what's there - but I wanted to know if this is bad practice for
any reason.


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.

Charles Yeomans




<Prev in Thread] Current Thread [Next in Thread>