Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.csd.uwm.edu!bionet!agate!ucbvax!hplabs!well!svc From: svc@well.UUCP (Leonard Rosenthol) Newsgroups: comp.sys.mac.programmer Subject: Re: File Manager question Summary: Here are the answers! Keywords: File Manager, prefs, whatever Message-ID: <13235@well.UUCP> Date: 20 Aug 89 07:23:54 GMT References: <15088@dartvax.Dartmouth.EDU> Reply-To: svc@well.UUCP (Leonard Rosenthol) Organization: Whole Earth 'Lectronic Link, Sausalito, CA Lines: 57 >I am fairly new to Mac Programming. The other day I tackled the >dreaded IM IV File Manager section because I am writing an application >that need to save some preference parameters. There are a number of >ways that I can think of solving this problem, but I can find a >solution or a safe solution to this: > >1) Saving the preferences in the data fork of the currently running >application. > DO NOT DO THIS! Writing to yourself (either in the datafork or the resource fork) is not recommended! Some of reasons for this include the fact that by doing so, you make you application no longer usuable from a server under certain conditions...and your users would not be very happy. > >2) Saving the preferences in a file in the currently blessed system >folder. > This is the Apple Approved (and in many ways the easiest) of the ways to save off preference info. >Question: How do I get the vRefNum of the current system Folder ? > Call SysEnvirons (IMV-5). One of the fields of the sysEnvRec which is returned to you is the sysVRefNum (ie. the vRefNum of the blessed system folder). Quick and painless. > >3) Saving the preference in a file in the same folder as the application >is in. > This will also work, but again this may also have problems on server volumes depending on the permissions of the apps folder. >Question: Similar question as in 1, how can I be sure that the default >working directory will not be changed ? is passing '0' as vRefNum always >safe? > What I would do to solve this one is to do a GetVol at the beginning of the application (right after the rest of the Toolbox inits) and that will give you the vRefNum of the appls folder for use in writing it out. This is also useful when you have owned files such as spelling dictionaries and help files. >Much thanks in advance > Anytime! +--------------------------------------------------+ Leonard Rosenthol | GEnie : MACgician Lazerware, inc. | MacNet: MACgician UUCP: svc@well.UUCP | ALink : D0025 -- +--------------------------------------------------+ Leonard Rosenthol | GEnie : MACgician Lazerware, inc. | MacNet: MACgician UUCP: svc@well.UUCP | ALink : D0025