Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!inebriae!crucible!al From: al@crucible.UUCP (Al Evans) Newsgroups: comp.sys.mac.programmer Subject: Re: Getting the full pathname? Summary: Routine to get full pathname Message-ID: <111@crucible.UUCP> Date: 15 Oct 89 17:57:30 GMT References: <850zebolskyd@yvax.byu.edu> Reply-To: al@crucible.UUCP (Al Evans) Followup-To: comp.sys.mac.programmer Organization: PowerTools, Austin, TX Lines: 62 In article <850zebolskyd@yvax.byu.edu> zebolskyd@yvax.byu.edu writes: >If you want the _user_ to be able to see the pathname (and find their way to >the file) you can use PBGetWDInfo to get the dirID from your working >directory, then PBGetCatInfo to get that directory's parent's dirID, and >so on until to get to dirID=2, which will be the root. You get the names ^^^^^^^ Although this seems to be true, it doesn't seem to be documented :-( >along the way from ioNamePtr. That's also how I get the volume name for >the volumename/dirID/filename resource I use to save a file's location >for future _machine_ use. I can send you Modula-2 source code if you want, >but you would probably be better off making your _own_ mistakes instead >of trying to find mine. > >--Lyle D. Gunderson zebolskyd@yvax.byu.edu CIS: 73760,2354 There are MANY good reasons for never using full pathnames in a Mac application. But I, too, have stumbled across situations where it was absolutely necessary. I found that the technique recommended above works, but was unable to find any guarantee that the root directory would ALWAYS have dirID=2. As far as I can tell, the following routine does not rely upon anything undocumented: -----cut about here-------- { Returns full pathname to folder specified by startID in thePath, where startID is the vRefNum/wdRefNum returned by SFGetFile or SFPutFile } PROCEDURE GetCurrentPath (startID : INTEGER; VAR thePath : Str255); VAR tempName : Str255; vParams : CInfoPBRec; theError : OSErr; BEGIN thePath := ''; tempName := ''; WITH vParams DO BEGIN ioCompletion := NIL; ioNamePtr := @tempName; ioVRefNum := startID; ioFDirIndex := -1; ioDrDirID := 0; REPEAT theError := PBGetCatInfo(@vParams, FALSE); IF (theError = noErr) THEN BEGIN ioDRDirID := ioDRParID; thePath := concat(tempName, ':', thePath); tempName := ''; END; UNTIL (theError <> noErr); END; END; --------cut somewhere near here, too------------- --Al Evans-- -- Al Evans "You'd grep to know what ...uunet!execu!sequoia!crucible!al you really sed." --Referent Blob