Article View: comp.sys.mac
Article #20911Re: Getting a vRefNum from a DirID
From: clubmac
Date: Thu, 29 Oct 1987 04:51
Date: Thu, 29 Oct 1987 04:51
64 lines
2307 bytes
2307 bytes
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.
Technical Details
Message-ID:
<1180@runx.ips.oz>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!water!watmath!clyde!cbosgd!ihnp4!homxb!mtuxo!mtune!rutgers!sri-spam!ames!sdcsvax!ucsdhub!esosun!seismo!uunet!munnari!otc!metro!ipso!runx!clubmacReferences:
<1006@mntgfx.MENTOR.COM>Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: arc1-ca.pugleaf.net!utzoo!utgpu!water!watmath!clyde!cbosgd!ihnp4!homxb!mtuxo!mtune!rutgers!sri-spam!ames!sdcsvax!ucsdhub!esosun!seismo!uunet!munnari!otc!metro!ipso!runx!clubmac From: clubmac@runx.UUCP Newsgroups: comp.sys.mac Subject: Re: Getting a vRefNum from a DirID Message-ID: <1180@runx.ips.oz> Date: Wed, 28-Oct-87 23:51:08 EST Article-I.D.: runx.1180 Posted: Wed Oct 28 23:51:08 1987 Date-Received: Sun, 1-Nov-87 07:43:21 EST References: <1006@mntgfx.MENTOR.COM> Reply-To: clubmac@runx.OZ (Macintosh Users Group - Sydney, Australia) Organization: RUNX Un*x Timeshare. Sydney, Australia. Lines: 64