From: aep@world.std.com (Andrew E Page)
Subject: Directory Scan Revisited
Organization: The World Public Access UNIX, Brookline, MA
Date: Tue, 1 Sep 1992 14:00:08 GMT


    I'm just about finished with the code for the directory scan code.  I've
incorporated some recomenedations from Apple, and I am in the process of
commenting the code heavily.  

   However, here is the interface file.  Comments and suggestestions are
welcome.  

--------CUT HERE------------------------------------------------CUT HERE------
#ifndef __DIRSCAN__
#define __DIRSCAN__
#ifndef __TYPES__
#include <Types.h>
#endif

Ptr StartDirScanDirID(short volRef, long dirID, int numTypes, OSType *TypeList, pascal Boolean (*filter)(FileParam *f)) ;
/*
*    StartDirScanDirID starts the directory scan, using a WDVRefNum.  
*    It will return 0L if the call failed or a pointer to be used
*    in subsequent calls.  
*
*
*     volRef    true volume reference where scan is to start.
*
*			dirID			directory on volume where scan is to start.    
*
*     numTypes  Number of types to limit scan too.
*               -1 indicates to scan all types.  
*
*     typeList  Array of OSTypes with numTypes elements.  
*               Pass 0L if numTypes is -1
*
*     filter    Filter proc of the variety used by SFGetFile.  
*               Pass 0L for no filtering.                 
*
*               pascal Boolean MyFilter(fileParamPtr *f) ;
*                  MyFilter returns TRUE if file is to be excluded.
*                    or FALSE if it isn't.   
*/

Ptr StartDirScanWDVRef(short vRef, short *volRef, int numTypes, OSType *TypeList, pascal Boolean (*filter)(FileParam *f)) ;
/*
*    StartDirScanWDVRef starts the directory scan, using a WDVRefNum.  
*    It will return 0L if the call failed or a pointer to be used
*    in subsequent calls.  
*
*
*     vRef      Volume/Directory where scan is to start.
*
*			volRef		pointer a short where the true volume reference
*								number is to be placed when call is complete.  
*
*     numTypes  Number of types to limit scan too.
*               -1 indicates to scan all types.  
*
*     typeList  Array of OSTypes with numTypes elements.  
*               Pass 0L if numTypes is -1
*
*     filter    Filter proc of the variety used by SFGetFile.  
*               Pass 0L for no filtering.                 
*
*               pascal Boolean MyFilter(fileParamPtr *f) ;
*                  MyFilter returns TRUE if file is to be excluded.
*                    or FALSE if it isn't.   
*/


OSErr GetNextDirScanFile(Ptr scanPtr, char *fName, long *dirID, long *level) ;
/*
*     Each call to GetNextScanFile will retreive the next file in the
*      directory tree.  GetNextScanFile will return a fnfErr when the
*      scan is completed.  
*
*
*  scanPtr     Ptr returned from StartScan
*
*  fName       string space for returned file name  (recommended length 64)
*
*  dirID        Pointer to a long where dirID reference for 
*              the directory that the file is in.   
*
*	 level				Pointer to a long where the level at which the file was found
*               (0 is the level where the scan started).  You can pass a 0L
*               in place of pointer if the level is not of interest.  
*                            
*/

OSErr StopDirScan(Ptr scanPtr) ;
/*
*    Terminates the scan started by Start scan.  
*
*     scanPtr    Ptr returned by StartScan.  
*
*     CAUTION... do not not attempt to use scanPtr again
*                after this call.  
*
*/


/*
*   Using information returned from GetNextScanFile this function
* will return a 'full pathname' as a handle.  The handle is the
* exact length of the string and is NOT preceded by a pascal length
* byte or folled by a C null terminator.  
*
*   fName      Name of the file.  
*
*		vRef       True volume reference number.
*
*   dirID      directory ID that the file resides in.  
*/
Handle FullPathNameID(char *fName, int vRef, long dirID) ;

#endif
-- 
Andrew E. Page CTO(Warrior Poet)|   Decision and Effort The Archer and Arrow
DSP Ironworks                   |     The difference between what we are
Macintosh and DSP Technology    |           and what we want to be.
Newsgroups: comp.sys.mac.programmer