tomc@mntgfx.MENTOR.COM (Tom Carstensen) (10/23/87)
Put simply, how do you get a volume reference number (like that return from a SFGetFile), from a directory ID? I've tried about everything! help! :------------------------------------------------------------: : Tom Carstensen Usenet: tomc@mntgfx.MENTOR.COM : : Mentor Graphics GEnie: : :------------------------------------------------------------:
stew@endor.harvard.edu (Stew Rubenstein) (10/25/87)
In article <1006@mntgfx.MENTOR.COM> tomc@mntgfx.MENTOR.COM (Tom Carstensen) writes: >Put simply, how do you get a volume reference number >(like that return from a SFGetFile), from a directory >ID? SFGetFile usually returns a working directory reference number, not a volume reference number. If you have a real volume reference number and a DirID, and you need a working directory reference number, use OpenWD. If you have only a DirID, and don't know which physical disk it is on, you don't have enough information. You could try walking the volume list with an indexed PBGetVInfo or somesuch, and try opening a Working Directory on each volume until you get one that succeeds... (Did I really suggest that? Must be late.) I suggest you study IM 4, p. 98 and TechNote 77. Stew Rubenstein Cambridge Scientific Computing, Inc. UUCPnet: seismo!harvard!rubenstein CompuServe: 76525,421 Internet: rubenstein@harvard.harvard.edu MCIMail: CSC
raylau@dasys1.UUCP (Raymond Lau) (10/25/87)
In article <1006@mntgfx.MENTOR.COM>, tomc@mntgfx.MENTOR.COM (Tom Carstensen) writes: > Put simply, how do you get a volume reference number > (like that return from a SFGetFile), from a directory > ID? The vRefNum returned by SFGetFile may actually be a volume ref num or it may be a working directory reference number. WD's were created so that pre- HFS applications can refer to folders w/one number. To create a WD given a vRefNum and a DirID, use PBOpenWD...and the Proc ID or 'ERIK' so that the Finder will dispose of unneeded WDs. (There is a limit of 40 WDs at any given time on current systems) To refer to the root of a volume (DirID}i = 2), just use the volume reference number.
clubmac@runx.UUCP (10/29/87)
In article <1006@mntgfx.MENTOR.COM> tomc@mntgfx.MENTOR.COM (Tom Carstensen) writes: >Put simply, how do you get a volume reference number >(like that return from a SFGetFile), from a directory >ID? > >I've tried about everything! help! Since I asked the same question a couple of months back and with the help of John O'Neill and Andrew Betzis, here is some LSC code to do the job. Jason Haines, President Club Mac Macintosh Users Group, Sydney, Australia Phone Home: +61-02-73-4444 Snail: Box 213, Holme Building, Sydney University, NSW, 2006, Australia ACSnet: clubmac@runx.ips.oz ARPA: clubmac%runx.ips.oz@seismo.css.gov UUCP:{enea,hplabs,mcvax,prlb2,seismo,ubc-vision,ukc}!munnari!runx.ips.oz!clubmac --- #include <HFS.h> #include <stdio.h> /* Given a working directory refnum, return the volume refnum and dirID. This assumes that HFS is installed on the machine. */ OSErr GetDirID(vRefNum,dirID) int *vRefNum; long *dirID; { WDPBRec pb; long result; pb.ioCompletion = NULL; pb.ioNamePtr = NULL; pb.ioVRefNum = *vRefNum; pb.ioWDIndex = 0; pb.ioWDProcID = 0; pb.ioWDVRefNum = *vRefNum; result = PBGetWDInfo(&pb, FALSE); *vRefNum = pb.ioWDVRefNum; *dirID = pb.ioWDDirID; return(result); } /* This is the reverse */ OSErr DirID2VRefNum(VRefNum,dirID) int *VRefNum long *dirID { WDPBRec theWD; OSErr err; theWD.ioCompletion = NULL; theWD.ioNamePtr = NULL; theWD.ioVRefNum = 0; theWD.ioWDDirID = *dirID; theWD.ioWDProcID = 'ERIK'; err = PBOpenWD(&theWD,FALSE); *VRefNum = theWD.ioVRefNum; return(err); } --- Hope this helps.
wrp@krebs.UUCP (10/31/87)
I have a related question, how do you get a directory name from a vRefNum? I would like to get file names using SFGetFile(), but then use LSC's fopen() to actually open the file. Bill Pearson wrp@virginia.EDU wrp@virginia.BITNET ...!uunet!virginia!wrp