laf@mitre.org (Lee Fyock) (05/15/91)
Does anyone have an easy way to get a refNum for a directory from its WD Dir ID? Or even a not-so-easy way? Thanks, Lee Fyock laf@mitre.org
laf@mitre.org (Lee Fyock) (05/15/91)
In article <1991May15.125921.15058@linus.mitre.org> laf@mitre.org (Me) writes: >Does anyone have an easy way to get a refNum for a directory from >its WD Dir ID? Or even a not-so-easy way? Let me explain further: I have a working directory dir ID and a refNum for an open file. I'm trying to find out if the given file is in the given directory. I've tried various incantations of PBGetWDInfo, but haven't found anything that will give me a way to find the directory of the open file. Any suggestions? Thanks, Lee Fyock laf@mitre.org
hairston@henry.ece.cmu.edu (David Hairston) (05/16/91)
[laf@mitre.org (Lee Fyock) writes:] [] Does anyone have an easy way to get a refNum for a directory from [] its WD Dir ID? Or even a not-so-easy way? not sure of the exact relationship between wdRefNums and vRefNums, if any, but the call GetWDInfo() will return the actual vRefNum, dirID, and procID for a given wdRefNum. GetWDInfo() is analogous to the PBGetWDInfo() call documented in Inside Mac IV - File Manager. For further details, see Tech Note 218 - New High Level File Manager Calls. using GetWDInfo() requires internal compiler support (glue) ... -dave- hairston@henry.ece.cmu.edu
laf@mitre.org (Lee Fyock) (05/16/91)
OK, I think I confused a lot of people (spreading my confusion around worked!), but thanks mostly to John Cavallino, I found that the combination of PBGetWDInfo and PBGetFCBInfo gave me the correct results. Thanks! Lee Fyock laf@mitre.org
ech@cbnewsk.att.com (ned.horvath) (05/16/91)
From article <1991May15.160944.19184@linus.mitre.org>, by laf@mitre.org (Lee Fyock): > In article <1991May15.125921.15058@linus.mitre.org> laf@mitre.org (Me) writes: >>Does anyone have an easy way to get a refNum for a directory from >>its WD Dir ID? Or even a not-so-easy way? > > Let me explain further: > > I have a working directory dir ID and a refNum for an open file. I'm > trying to find out if the given file is in the given directory. I've tried > various incantations of PBGetWDInfo, but haven't found anything that will > give me a way to find the directory of the open file. AH, now I can help you (I tried already, but my mail bounced). You want to pass the file refNum to PBGetFCBInfo (IM IV-179). It returns the infamous triple -- vRefNum, dirID, and filename -- that you need to uniquely identify the file. -- =Ned Horvath= ehorvath@attmail.com
wysocki@husc9.harvard.edu (Christopher Wysocki) (05/17/91)
In article <1991May15.160944.19184@linus.mitre.org> laf@mitre.org (Lee Fyock) writes: >I have a working directory dir ID and a refNum for an open file. I'm >trying to find out if the given file is in the given directory. I've tried >various incantations of PBGetWDInfo, but haven't found anything that will >give me a way to find the directory of the open file. > >Any suggestions? How about calling PBGetFCBInfo to get the directory ID, then comparing this directory ID to that returned by PBGetWDInfo? Something like: Boolean FileInWorkingDirectory(short refNum, short wdRefNum) { FCBPBRec fcbpb; OSErr err; Str63 fileName; WDPBRec wdpb; fcbpb.ioNamePtr = (unsigned char *) fileName; fcbpb.ioVRefNum = 0; fcbpb.ioRefNum = refNum; fcbpb.ioFCBIndx = 0; err = PBGetFCBInfo(&fcbpb, FALSE); wdpb.ioVRefNum = wdRefNum; wdpb.ioWDIndex = 0; wdpb.ioWDProcID = 0; wdpb.ioWDVRefNum = 0; err = PBGetWDInfo(&wdpb, FALSE); return (fcbpb.ioFCBParID == wdpb.ioWDDirID); } This is off the top of my head, but I think it should work. Chris Wysocki wysocki@husc9.harvard.edu