🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.mac
Article #1368

Saving vRefNum's

#1368
From: Steve Leeke
Date: Thu, 13 Jul 1989 22:41
78 lines
2043 bytes
I would like to be able to recursively scavange a directory for a
certain type of file and save the vRefNum when a file of a certain
type is found.  I've included to code I'm using by it seems to cause
problems since the working directory is closed after I save the
vRefNum, but if I leave it open I wind up with too many working
directories open.  Any suggestions?

Thanks,

Steve Leeke
leeke@m2.csc.ti.com


/* - */
Boolean scavengeDirectory(dirName,vRefNum,wPtr)
StringPtr	dirName;
INT		vRefNum;
WindowPtr	wPtr;
/* - */
{
	OSErr		err;
	Str255		fileName;
	HFileInfo	dirRec;
	WDPBRec		dirWDRec;
	INT		index;
	Boolean		result;


	result	=	false;

	dirWDRec.ioCompletion	=	NULL;
	dirWDRec.ioNamePtr	=	dirName;

	dirWDRec.ioVRefNum	=	vRefNum;
	dirWDRec.ioWDProcID	=	0;
	dirWDRec.ioWDDirID	=	0;

	if (PBOpenWD(&dirWDRec,false) == noErr) {
	index	=	1;

	do {
		dirRec.ioCompletion	=	NULL;
		dirRec.ioNamePtr	=	fileName;
		dirRec.ioVRefNum	=	dirWDRec.ioVRefNum;
	
		dirRec.ioFDirIndex	=	index;
		dirRec.ioDirID		=	0;
	
		err	=	PBGetCatInfo((CInfoPBPtr) &dirRec,false);
	
		if (err == noErr) {
			if (((dirRec.ioFlAttrib >> 4) & 0x01) != 0) {
			/*
				We have a directory.
			*/
					
		if (scavengeDirectory(fileName,dirWDRec.ioVRefNum,wPtr)) {
			result	=	true;
			break;
		};
		} else {
			if (dirRec.ioFlFndrInfo.fdType == XPRCSignature) {
				/*	
					Save vRefNum.
				*/
				result	=	true;
			};
		};
		};
	
			index++;
		} while (err != fnfErr);

		PBCloseWD(&dirWDRec,false);
	};

	return(result);
};
Technical Details
Message-ID: <84039@ti-csl.csc.ti.com>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!cs.utexas.edu!sun-barr!newstop!texsun!pollux!ti-csl!m2!leeke

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!cs.utexas.edu!sun-barr!newstop!texsun!pollux!ti-csl!m2!leeke
From: leeke@m2.csc.ti.com (Steve Leeke)
Newsgroups: comp.sys.mac,comp.sys.mac.programmer
Subject: Saving vRefNum's
Message-ID: <84039@ti-csl.csc.ti.com>
Date: 13 Jul 89 22:41:13 GMT
Sender: news@ti-csl.csc.ti.com
Reply-To: leeke@m2.UUCP (Steve Leeke)
Followup-To: comp.sys.mac
Organization: TI Computer Science Center, Dallas
Lines: 78