Xref: utzoo comp.sys.mac:26717 comp.sys.mac.programmer:4477 Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!hoptoad!tim From: tim@hoptoad.uucp (Tim Maroney) Newsgroups: comp.sys.mac,comp.sys.mac.programmer Subject: Re: What's the "best" way to save a file? Message-ID: <6524@hoptoad.uucp> Date: 14 Feb 89 12:10:49 GMT References: <1811@cps3xx.UUCP> Reply-To: tim@hoptoad.UUCP (Tim Maroney) Organization: Eclectic Software, San Francisco Lines: 31 In article <1811@cps3xx.UUCP> rang@cpswh.cps.msu.edu (Anton Rang) writes: > 1. If doing "Save As", ask the user for the filename. > 2. Write out the new file, with some temporary name. > 3. Rename the "old file," if it exists, to a temporary name. > 4. Rename the new file to the old file's name. > 5. Delete the old file. > > The "old file" is the existing file; the "new file" is the one just >being saved. The advantage of doing this is that the old file isn't >removed until the new file has been successfully written. The >disadvantage is that you can't use "Save As" to free up disk space by >saving on top of an existing file. > What do people think of this idea? What are the biggest problems >you see with it? It's a great appraoch, the one emacs uses. There's only one big problem -- you have to have enough disk space for both copies of the file. This is quite likely not to be the case on floppies. You should build in a check so that, if there isn't enough disk space for both copies, you just overwrite the existing file in the "naive" way. Don't notify the user, as it would only be confusing. By the way, Save As must be able to save over an existing file. I don't see why that wouldn't work in this approach, though. -- Tim Maroney, Consultant, Eclectic Software, sun!hoptoad!tim "The Diabolonian position is new to the London playgoer of today, but not to lovers of serious literature. From Prometheus to the Wagnerian Siegfried, some enemy of the gods, unterrified champion of those oppressed by them, has always towered among the heroes of the loftiest poetry." - Shaw, "On Diabolonian Ethics"