Path: utzoo!attcan!uunet!husc6!bloom-beacon!apple!darin From: darin@Apple.COM (Darin Adler) Newsgroups: comp.sys.mac.programmer Subject: Re: Setting a default folder Keywords: FSGetFile Message-ID: <20676@apple.Apple.COM> Date: 16 Nov 88 00:30:42 GMT References: <63398@ti-csl.CSNET> <1479@murdu.OZ> Organization: Apple Lines: 35 In article <1479@murdu.OZ> grae@murdu.UUCP (Graeme Gerrard) writes: > > topaz.rutgers.edu wants to know about setting default directories. > > From memory, what you need is to get the ioWDDirID of the > directory you want as your default. If you only know the > NAME of the directory, you can get the ioWDDirID by calling > PBHSetVol, passing a WDPBRec with the name in ioNamePtr, > ioVRefNum = 0 and ioWDDirID = 0L. > Then call PBHGetVol and with the same parameter block and it > returns the ioWDDirID of the directory you are after. > Now set the global, CurDirStore, to the ioWDDirID, and call > SFGet/PutFile. The result is a "set directory" before you get > your dialog box up. In general, this advice is good. However, a PBHSetVol followed by a PBHGetVol is *not* a good way to get the dirID from a working directory (or name of a directory). If you have the name of a directory and need the dirID, you can use the GetCatInfo call to get it. Pass the name of the the file in ioNamePtr, and set ioFDirIndex to 0. The dirID will come back in ioDrDirID. Note that you should also check if it is a directory rather than a file by looking at bit 4 of ioFlAttrib. Then you should set the low memory global SFSaveDisk to -vRefNum, where vRefNum is the volume reference number of the disk which the directory is on and set CurDirStore the dirID (from ioDrDirID). For more information see page IV-125 of Inside Macintosh ("CInfoPBRec"), page IV-155 of Inside Macintosh ("PBGetCatInfo"), Technical Note #69 ("Setting ioFDirIndex in PBGetCatInfo Calls"), Technical Note #80 ("Standard File Tips"), and Technical Note #140 ("Why PBHSetVol is Dangerous"). -- Darin Adler AppleLink: Adler4 UUCP: {sun,voder,nsc,mtxinu,dual}!apple!darin CSNET: darin@Apple.com