Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!wuarchive!gem.mps.ohio-state.edu!apple!well!svc From: svc@well.UUCP (Leonard Rosenthol) Newsgroups: comp.sys.mac.programmer Subject: Re: INIT getting it's file name... Summary: You got me on that one, sort of.. Message-ID: <14385@well.UUCP> Date: 31 Oct 89 17:40:01 GMT References: <56505@tiger.oxy.edu> <4020@helios.ee.lbl.gov> <14362@well.UUCP> <8851@hoptoad.uucp> Reply-To: svc@well.UUCP (Leonard Rosenthol) Organization: Whole Earth 'Lectronic Link, Sausalito, CA Lines: 44 In article <8851@hoptoad.uucp> tim@hoptoad.UUCP (Tim Maroney) writes: >In article <14362@well.UUCP> svc@well.UUCP (Leonard Rosenthol) writes: >> I don't know what all this mess is about searching the System Folder, >>etc. as that is a REAL PAIN, > >What? How? I've done it in several pieces of code. The File Manager >makes it tremendously easy, by using indexed files with PBGetFInfo. >It's a very straightforward loop! > I probably should have rephrased that statement. I did not meant that coding a search of the System Folder is difficult, it is certainly not. However many people out there (myself included) have LOTS of files in the System Folder (many of which are prefs, unused INITS, etc.) and it takes TIME to do the search each and every time the user invokes your INIT. >>So here is the piece of code that >>I use for getting not only my INIT's name, but also the vRefNum (OK, WDRefNum) >>where I am. > >But like about three-quarters of the people who answered this question, >you ignored his explicitly stated requirement that he wants the user to >be able to rename the file. That means that he can't just save the >file name at INIT run time, because it could change -- and later, he >can't use CurrResFile to find out its file descriptor! PBGetFCBInfo >is completely irrelevant to this problem. > It is true that this does not provide for renaming on the fly, but it does provide for non-hardcoding names so that it could be renamed before use or by turning it off, renaming and turning it back on - not the greatest BUT much better than hardcoding!! It appears to me that a combination of our two methods would be the best bet. First the INIT checks for the values it stored at startup with the PBGetFCBInfo and GetVol calls - if the file with that info does not exist then it can perform a search to find it based on the creator - HOWEVER the search could possibly be two-fold. The search should start in the vRefNum returned by GetVol, and if that value is NOT the same as mySysEnvRec.sysVRefNum then the System Folder should also be searched in case the user moved it. How's that for an all purpose, and cover most/all cases solution?!??!? -- +--------------------------------------------------+ Leonard Rosenthol | GEnie : MACgician Lazerware, inc. | MacNet: MACgician UUCP: svc@well.UUCP | ALink : D0025