Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!gem.mps.ohio-state.edu!apple!apple.COM!han From: han@apple.COM (Byron Han, Project Scapegoat) Newsgroups: comp.sys.mac.programmer Subject: Re: INIT getting it's file name... Message-ID: <4950@internal.Apple.COM> Date: 28 Oct 89 02:24:15 GMT Sender: usenet@Apple.COM Distribution: usa Organization: Apple Computer, Inc. - N&C Lines: 41 References:<56505@tiger.oxy.edu> <4020@helios.ee.lbl.gov> <5511@umd5.umd.edu> In article <56505@tiger.oxy.edu> sonenbli@oxy.edu (Andrew D. Sonenblick) writes: > Ok, this is a quick one but it is very important: is there any way > for an INIT to get the name of the file it is in? I need to later open > the resource fork of the file and I want the user to be able to change the > name of the file; hence, my INIT needs to be able to read in the file name. Ok. Here is how to do itI 1. Do a RecoverHandle on your entry point to get the INIT handle 2. Do a HomeResFile to get the resource file refnum of the INIT file 3. You can convert the resource file refnum (which is just a file refnum) into a filename/working directory refnum pair via a call to PBGetFCPInfo 4. The wdRefNum can be converted into a vRefNum/dirID pair via a call to PBGetWDInfo But why do you want the name of your INIT file? You should NOT hard code - the user may wish to rename their INIT files and indeed may do so. +-------------------------------------------------------------------------- ---+ | Disclaimer: Apple has no connection with my postings. | +-------------------------------------------------------------------------- ---+ Byron Han, CommToolbox Scapegoat "DeAnza 3 - R.I.P. - 10/17/89 5:04PM" Apple Computer, Inc. ----------------------------------------- 20525 Mariani Ave, MS 69L Internet: han@apple.COM Cupertino, CA 95014 UUCP:{sun,voder,nsc,decwrl}!apple!han ------------------------------------ GENIE:BYRONHAN CompuServe:72167,1664 ATTnet: 408-974-6450 Applelink:HAN1 HAN1@applelink.apple.COM --------------------------------------------------------------------------- ---