Xref: utzoo comp.sys.mac:26697 comp.sys.mac.programmer:4471 Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!eecae!cps3xx!rang From: rang@cpsin3.cps.msu.edu (Anton Rang) Newsgroups: comp.sys.mac,comp.sys.mac.programmer Subject: What's the "best" way to save a file? Message-ID: <1811@cps3xx.UUCP> Date: 14 Feb 89 04:16:23 GMT Sender: usenet@cps3xx.UUCP Reply-To: rang@cpswh.cps.msu.edu (Anton Rang) Distribution: na Organization: Michigan State University, Computer Science Dept. Lines: 24 While watching all the discussion on the great Microsoft Word Save As fiasco, I started thinking about the best way to do a "Save As" (or a "Save", for that matter). It seems to me that the following is the safest way to do it, if the file is going to be saved "on top of" an existing file. 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? +---------------------------+------------------------+----------------------+ | Anton Rang (grad student) | Things could be worse. | "Do worry...be SAD!" | | Michigan State University | rang@cpswh.cps.msu.edu | | +---------------------------+------------------------+----------------------+