Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!elroy.jpl.nasa.gov!ncar!hsdndev!husc3.harvard.edu!husc9.harvard.edu!wysocki From: wysocki@husc9.harvard.edu (Christopher Wysocki) Newsgroups: comp.sys.mac.programmer Subject: Re: refNum from WD DirID? Message-ID: <1991May16.225533.1017@husc3.harvard.edu> Date: 17 May 91 02:55:31 GMT References: <1991May15.125921.15058@linus.mitre.org> <1991May15.160944.19184@linus.mitre.org> Organization: Harvard University, Cambridge, MA Lines: 40 Nntp-Posting-Host: husc9.harvard.edu 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