Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!purdue!ames!elroy!usc!hacgate!ashtate!dbase!awd From: awd@dbase.UUCP (Alastair Dallas) Newsgroups: comp.sys.mac.programmer Subject: Re: Mac file IO Summary: File name is enough Message-ID: <93@dbase.UUCP> Date: 9 Jun 89 00:59:11 GMT References: <16464@paris.ics.uci.edu> <3264@cps3xx.UUCP> Organization: Ashton Tate Devlopment Center Glendale, Calif. Lines: 39 In article <3264@cps3xx.UUCP>, rang@cpsin3.cps.msu.edu (Anton Rang) writes: > In article <16464@paris.ics.uci.edu> poleary@BONNIE.ICS.UCI.EDU (Peter O'Leary) writes: > > An application that I am working on needs to save information on a file so > that that file may be opened later. What is the minimum amount of info [] > that is needed in order to get at a file? So far, I have been storing the > file's name and volume reference number. > > It depends on how much later you need the file, to some extent, but > what I'd recommend storing is: > > Volume name (refnum is only valid for one session) > Directory ID (for an HFS volume) > File name > Like another current thread in comp.sys.mac.programmer, I think the answer here is: "There is already a Macintosh way of doing this." The minimum amount of information to store is whatever the user enters to name the file in the first place. If she renames the file or shuffles directories between the time she writes the file and the time she reads the file, the program should just politely pull up SFGetFile and say "where the H*ll is ?". Of course, if she navigates in SFPutFile, you might want the Volume and Directory, but you want to ignore those things if the user ignored them (used the default working directory) when she saved the file. The way to detect navigation in SFPutFile is to compare the working directory before and after the SFPutFile call (that's off the top of my head, I'll be corrected if I'm wrong, I'm sure). User brings up your program, writes out a file by doing nothing more than typing Foo in the SFPutFile dialog. Back at Finder, realizes that Foo is now in same folder as the program. Moves Foo to a floppy. Months later, inserts floppy, dbl-clicks Foo--your program tells him forget it because Volume and Directory don't match? Wouldn't be friendly... (Long-winded today, aren't I?) /alastair/