2      File:       IterateDirectory.h 
   4      Contains:   File Manager directory iterator routines. 
   6      Version:    Technology: MoreFiles 
   9      Copyright:  © 1995-2001 by Jim Luther and Apple Computer, Inc., all rights reserved. 
  11      Bugs?:      For bug reports, consult the following page on 
  14                      http://developer.apple.com/bugreporter/ 
  19     You may incorporate this sample code into your applications without 
  20     restriction, though the sample code has been provided "AS IS" and the 
  21     responsibility for its operation is 100% yours.  However, what you are 
  22     not permitted to do is to redistribute the source as "DSC Sample Code" 
  23     after having made changes. If you're going to re-distribute the source, 
  24     we require that you make it clear in the source that the code was 
  25     descended from Apple Sample Code, but that you've made changes. 
  28 #ifndef __ITERATEDIRECTORY__ 
  29 #define __ITERATEDIRECTORY__ 
  39 #include "Optimization.h" 
  54 #if PRAGMA_STRUCT_ALIGN 
  55     #pragma options align=mac68k 
  56 #elif PRAGMA_STRUCT_PACKPUSH 
  58 #elif PRAGMA_STRUCT_PACK 
  62 /*****************************************************************************/ 
  64 typedef CALLBACK_API( void , IterateFilterProcPtr 
)(const CInfoPBRec 
*cpbPtr
, Boolean 
*quitFlag
, void *yourDataPtr
); 
  66     This is the prototype for the IterateFilterProc function which is 
  67     called once for each file and directory found by IterateDirectory. The 
  68     IterateFilterProc gets a pointer to the CInfoPBRec that IterateDirectory 
  69     used to call PBGetCatInfo. The IterateFilterProc can use the read-only 
  70     data in the CInfoPBRec for whatever it wants. 
  72     If the IterateFilterProc wants to stop IterateDirectory, it can set 
  73     quitFlag to true (quitFlag will be passed to the IterateFilterProc 
  76     The yourDataPtr parameter can point to whatever data structure you might 
  77     want to access from within the IterateFilterProc. 
  79     cpbPtr      input:  A pointer to the CInfoPBRec that IterateDirectory 
  80                         used to call PBGetCatInfo. The CInfoPBRec and the 
  81                         data it points to must not be changed by your 
  83     quitFlag    output: Your IterateFilterProc can set quitFlag to true 
  84                         if it wants to stop IterateDirectory. 
  85     yourDataPtr input:  A pointer to whatever data structure you might 
  86                         want to access from within the IterateFilterProc. 
  90     Also see:   IterateDirectory, FSpIterateDirectory 
  92 #define CallIterateFilterProc(userRoutine, cpbPtr, quitFlag, yourDataPtr) \ 
  93     (*(userRoutine))((cpbPtr), (quitFlag), (yourDataPtr)) 
  95 /*****************************************************************************/ 
 101   ConstStr255Param       name
, 
 102   unsigned short         maxLevels
, 
 103   IterateFilterProcPtr   iterateFilter
, 
 108     The IterateDirectory function performs a recursive iteration (scan) of 
 109     the specified directory and calls your IterateFilterProc function once 
 110     for each file and directory found. 
 112     The maxLevels parameter lets you control how deep the recursion goes. 
 113     If maxLevels is 1, IterateDirectory only scans the specified directory; 
 114     if maxLevels is 2, IterateDirectory scans the specified directory and 
 115     one subdirectory below the specified directory; etc. Set maxLevels to 
 116     zero to scan all levels. 
 118     The yourDataPtr parameter can point to whatever data structure you might 
 119     want to access from within the IterateFilterProc. 
 121     vRefNum         input:  Volume specification. 
 122     dirID           input:  Directory ID. 
 123     name            input:  Pointer to object name, or nil when dirID 
 124                             specifies a directory that's the object. 
 125     maxLevels       input:  Maximum number of directory levels to scan or 
 126                             zero to scan all directory levels. 
 127     iterateFilter   input:  A pointer to the routine you want called once 
 128                             for each file and directory found by 
 130     yourDataPtr     input:  A pointer to whatever data structure you might 
 131                             want to access from within the IterateFilterProc. 
 135         nsvErr              -35     No such volume 
 137         bdNamErr            -37     Bad filename 
 138         fnfErr              -43     File not found 
 139         paramErr            -50     No default volume or iterateFilter was NULL 
 140         dirNFErr            -120    Directory not found or incomplete pathname 
 141                                     or a file was passed instead of a directory 
 142         afpAccessDenied     -5000   User does not have the correct access 
 143         afpObjectTypeErr    -5025   Directory not found or incomplete pathname 
 147     See also:   IterateFilterProcPtr, FSpIterateDirectory 
 150 /*****************************************************************************/ 
 155   unsigned short         maxLevels
, 
 156   IterateFilterProcPtr   iterateFilter
, 
 161     The FSpIterateDirectory function performs a recursive iteration (scan) 
 162     of the specified directory and calls your IterateFilterProc function once 
 163     for each file and directory found. 
 165     The maxLevels parameter lets you control how deep the recursion goes. 
 166     If maxLevels is 1, FSpIterateDirectory only scans the specified directory; 
 167     if maxLevels is 2, FSpIterateDirectory scans the specified directory and 
 168     one subdirectory below the specified directory; etc. Set maxLevels to 
 169     zero to scan all levels. 
 171     The yourDataPtr parameter can point to whatever data structure you might 
 172     want to access from within the IterateFilterProc. 
 174     spec            input:  An FSSpec record specifying the directory to scan. 
 175     maxLevels       input:  Maximum number of directory levels to scan or 
 176                             zero to scan all directory levels. 
 177     iterateFilter   input:  A pointer to the routine you want called once 
 178                             for each file and directory found by 
 180     yourDataPtr     input:  A pointer to whatever data structure you might 
 181                             want to access from within the IterateFilterProc. 
 185         nsvErr              -35     No such volume 
 187         bdNamErr            -37     Bad filename 
 188         fnfErr              -43     File not found 
 189         paramErr            -50     No default volume or iterateFilter was NULL 
 190         dirNFErr            -120    Directory not found or incomplete pathname 
 191         afpAccessDenied     -5000   User does not have the correct access 
 192         afpObjectTypeErr    -5025   Directory not found or incomplete pathname 
 196     See also:   IterateFilterProcPtr, IterateDirectory 
 199 /*****************************************************************************/ 
 201 #include "OptimizationEnd.h" 
 203 #if PRAGMA_STRUCT_ALIGN 
 204     #pragma options align=reset 
 205 #elif PRAGMA_STRUCT_PACKPUSH 
 207 #elif PRAGMA_STRUCT_PACK 
 211 #ifdef PRAGMA_IMPORT_OFF 
 221 #endif /* __ITERATEDIRECTORY__ */