Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!batcomputer!caen!zaphod.mps.ohio-state.edu!swrinde!cs.utexas.edu!uunet!europa.asd.contel.com!noc.sura.net!haven.umd.edu!ni.umd.edu!ni.umd.edu!zben From: zben@ni.umd.edu (Ben Cranston) Newsgroups: comp.sys.mac.programmer Subject: Re: out to do PBCatSearch based on type/creator Summary: Example use of PBCatSearch to search a directory Message-ID: <1991Jun28.023718.11607@ni.umd.edu> Date: 28 Jun 91 02:37:18 GMT References: <1991Jun18.032741.24056@cec1.wustl.edu> <14194@goofy.Apple.COM> Sender: usenet@ni.umd.edu (USENET News System) Distribution: usa Organization: University of Maryland at College Park Lines: 100 Nntp-Posting-Host: ni.umd.edu I'm hacking up MacTCP's dnr.c routine to handle all four permutations of System 6/7 and MacTCP 1.0.2/1.1b1 and got this code to work for finding the MacTCP file in the Control Panels folder in order to find the dnrp resource. BTW System 6.0.7 vs MacTCP 1.1b1 seems to destroy the system file fairly reliably on a Mac SE I'm using for testing. Throw away the GetCPanelFolder subroutine and substitute these two routines for the existing OpenOurRF routine: /* FindFile is used to search Sys7 folder for file with specific signature */ short FindFile(FSSpec *myFSS, OSType mytype, OSType mycreator) { CSParam find; CInfoPBRec spec1, spec2; short err; find.ioNamePtr = nil; find.ioVRefNum = myFSS->vRefNum; find.ioMatchPtr = myFSS; find.ioReqMatchCount = 1; find.ioSearchBits = fsSBFlAttrib + fsSBFlFndrInfo + fsSBFlParID; find.ioSearchInfo1 = &spec1; find.ioSearchInfo2 = &spec2; find.ioSearchTime = 0; find.ioCatPosition.initialize = 0; find.ioOptBuffer = nil; find.ioOptBufSize = 0; spec1.hFileInfo.ioFlAttrib = 0; spec2.hFileInfo.ioFlAttrib = 0x10; spec1.hFileInfo.ioFlFndrInfo.fdType = mytype; spec1.hFileInfo.ioFlFndrInfo.fdCreator = mycreator; spec2.hFileInfo.ioFlFndrInfo.fdType = 0xFFFFFFFF; spec2.hFileInfo.ioFlFndrInfo.fdCreator = 0xFFFFFFFF; spec2.hFileInfo.ioFlFndrInfo.fdFlags = 0x0000; spec2.hFileInfo.ioFlFndrInfo.fdLocation.h = 0x0000; spec2.hFileInfo.ioFlFndrInfo.fdLocation.v = 0x0000; spec2.hFileInfo.ioFlFndrInfo.fdFldr = 0x0000; spec1.hFileInfo.ioFlParID = myFSS->parID; spec2.hFileInfo.ioFlParID = myFSS->parID; /* ???? */ err = PBCatSearch(&find,false); if (0 < find.ioActMatchCount) return(0); return(fnfErr); } /* OpenOurRF is called to open the MacTCP driver resources */ short OpenOurRF() { Boolean isFolder, wasAlias; SysEnvRec info; Boolean hasFolderMgr; long feature; FSSpec myFSS; ParamBlockRec fi; hasFolderMgr = ( TrapAvailable(_GestaltDispatch) && (noErr==Gestalt(gestaltFindFolderAttr,&feature)) ); if (hasFolderMgr) { if ( FindFolder(kOnSystemDisk, kControlPanelFolderType, kDontCreateFolder, &myFSS.vRefNum, &myFSS.parID ) != noErr) return(-1); if (noErr != FindFile(&myFSS,'cdev','ztcp')) if (noErr != FindFile(&myFSS,'cdev','mtcp')) return(-1); if (noErr != ResolveAliasFile(&myFSS,true,&isFolder,&wasAlias)) return(-1); return( FSpOpenResFile(&myFSS, fsRdPerm) ); } else { SysEnvirons(1, &info); fi.fileParam.ioVRefNum = info.sysVRefNum; fi.fileParam.ioNamePtr = &myFSS.name; fi.fileParam.ioFDirIndex = 1; while (noErr == PBGetFInfo(&fi,false) ) { /* scan sys folder for files of MacTCP type & creator */ if (fi.fileParam.ioFlFndrInfo.fdType == 'cdev' && (fi.fileParam.ioFlFndrInfo.fdCreator == 'ztcp' || fi.fileParam.ioFlFndrInfo.fdCreator == 'mtcp') ) /* found the MacTCP driver file */ return( OpenRFPerm(&myFSS.name,info.sysVRefNum, fsRdPerm) ); /* check next file in system folder */ fi.fileParam.ioFDirIndex++; } } return(-1); } I wasn't quite sure what to put into spec2.hFileInfo.ioFlParID for a parent-ID search. IM VI was silent on if this is a high-low range, a mask or it is just ignored. Anybody from Apple want to comment on this???? DE KA3ZDF K