4 Contains: IndexedSearch and the PBCatSearch compatibility function.
6 Version: Technology: MoreFiles
9 Copyright: © 1992-2001 by 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.
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 /*****************************************************************************/
71 The IndexedSearch function performs an indexed search in and below the
72 specified directory using the same parameters (in pb) as is passed to
73 PBCatSearch. See Inside Macintosh: Files for a description of the
76 pb input: A CSParamPtr record specifying the volume to search
77 and the search criteria.
78 output: Fields in the parameter block are returned indicating
79 the number of matches found, the matches, and if the
80 search ended with noErr, the CatPosition record that
81 lets you resume a search where the last search left
83 dirID input: The directory to search. If fsRtDirID is passed,
84 the entire volume is searched.
86 Note: If you use a high-level debugger and use ioSearchTime to limit
87 the length of time to run the search, you'll want to step over
88 calls to IndexedSearch because it installs a Time Manager task.
89 Most high-level debuggers don't deal gracefully with interrupt
94 nsvErr -35 Volume not found
96 eofErr -39 End of catalog found (this is normal!)
97 paramErr -50 Parameter block has invalid parameters
98 (see source for VerifyUserPB) or
99 invalid catPosition record was passed
100 extFSErr -58 External file system error - no file
101 system claimed this call.
102 memFullErr -108 Memory could not be allocated in heap
103 catChangedErr -1304 Catalog has changed and catalog position
104 record may be invalid
108 See also: PBCatSearch, PBCatSearchSyncCompat
111 /*****************************************************************************/
114 PBCatSearchSyncCompat(CSParamPtr paramBlock
);
118 The PBCatSearchSyncCompat function uses PBCatSearch (if available) or
119 IndexedSearch (if PBCatSearch is not available) to search a volume
120 using a set of search criteria that you specify. It builds a list of all
121 files or directories that meet your specifications.
123 pb input: A CSParamPtr record specifying the volume to search
124 and the search criteria.
125 output: Fields in the parameter block are returned indicating
126 the number of matches found, the matches, and if the
127 search ended with noErr, the CatPosition record that
128 lets you resume a search where the last search left
131 Note: If you use a high-level debugger and use ioSearchTime to limit
132 the length of time to run the search, you'll want to step over
133 calls to PBCatSearchSyncCompat because it calls IndexedSearch
134 which installs a Time Manager task. Most high-level debuggers
135 don't deal gracefully with interrupt driven code.
139 nsvErr -35 Volume not found
141 eofErr -39 End of catalog found (this is normal!)
142 paramErr -50 Parameter block has invalid parameters
143 (see source for VerifyUserPB) or
144 invalid catPosition record was passed
145 extFSErr -58 External file system error - no file
146 system claimed this call.
147 memFullErr -108 Memory could not be allocated in heap
148 catChangedErr -1304 Catalog has changed and catalog position
149 record may be invalid
150 afpCatalogChanged -5037 Catalog has changed and search cannot
155 See also: PBCatSearch, IndexedSearch
158 /*****************************************************************************/
162 ConstStr255Param volName
,
164 ConstStr255Param fileName
,
167 long * actMatchCount
,
173 The NameFileSearch function searches for files with a specific file
174 name on a volume that supports PBCatSearch.
175 Note: A result of catChangedErr means the catalog has changed between
176 searches, but the search can be continued with the possiblity that you
177 may miss some matches or get duplicate matches. For all other results
178 (except for noErr), the search cannot be continued.
180 volName input: A pointer to the name of a mounted volume
182 vRefNum input: Volume specification.
183 fileName input: The name of the file to search for.
184 matches input: Pointer to array of FSSpec where the match list is
186 reqMatchCount input: Maximum number of matches to return (the number of
187 elements in the matches array).
188 actMatchCount output: The number of matches actually returned.
189 newSearch input: If true, start a new search. If false and if
190 vRefNum is the same as the last call to
191 NameFileSearch, then start searching at the
192 position where the last search left off.
193 partial input: If the partial parameter is false, then only files
194 that exactly match fileName will be found. If the
195 partial parameter is true, then all file names that
196 contain fileName will be found.
200 nsvErr -35 Volume not found
202 eofErr -39 End of catalog found (this is normal!)
203 paramErr -50 Parameter block has invalid parameters
204 (see source for VerifyUserPB) or
205 invalid catPosition record was passed
206 extFSErr -58 External file system error - no file
207 system claimed this call.
208 memFullErr -108 Memory could not be allocated in heap
209 catChangedErr -1304 Catalog has changed and catalog position
210 record may be invalid
211 afpCatalogChanged -5037 Catalog has changed and search cannot
216 Also see: CreatorTypeFileSearch
219 /*****************************************************************************/
222 CreatorTypeFileSearch(
223 ConstStr255Param volName
,
229 long * actMatchCount
,
234 The CreatorTypeFileSearch function searches for files with a specific
235 creator or fileType on a volume that supports PBCatSearch.
236 Note: A result of catChangedErr means the catalog has changed between
237 searches, but the search can be continued with the possiblity that you
238 may miss some matches or get duplicate matches. For all other results
239 (except for noErr), the search cannot be continued.
241 volName input: A pointer to the name of a mounted volume
243 vRefNum input: Volume specification.
244 creator input: The creator type of the file to search for.
245 To ignore the creator type, pass 0x00000000 in
247 fileType input: The file type of the file to search for.
248 To ignore the file type, pass 0x00000000 in
250 matches input: Pointer to array of FSSpec where the match list is
252 reqMatchCount input: Maximum number of matches to return (the number of
253 elements in the matches array).
254 actMatchCount output: The number of matches actually returned.
255 newSearch input: If true, start a new search. If false and if
256 vRefNum is the same as the last call to
257 CreatorTypeFileSearch, then start searching at the
258 position where the last search left off.
262 nsvErr -35 Volume not found
264 eofErr -39 End of catalog found (this is normal!)
265 paramErr -50 Parameter block has invalid parameters
266 (see source for VerifyUserPB) or
267 invalid catPosition record was passed
268 extFSErr -58 External file system error - no file
269 system claimed this call.
270 memFullErr -108 Memory could not be allocated in heap
271 catChangedErr -1304 Catalog has changed and catalog position
272 record may be invalid
273 afpCatalogChanged -5037 Catalog has changed and search cannot
278 Also see: NameFileSearch
281 /*****************************************************************************/
283 #include "OptimizationEnd.h"
285 #if PRAGMA_STRUCT_ALIGN
286 #pragma options align=reset
287 #elif PRAGMA_STRUCT_PACKPUSH
289 #elif PRAGMA_STRUCT_PACK
293 #ifdef PRAGMA_IMPORT_OFF
303 #endif /* __SEARCH__ */