/* --------- Local Code --------- */ // static OSErr enumerate_files( // struct find_file_pb *param_block, // long directory_id) /* Because it is recursive.. */ bool FileFinder::Enumerate(DirectorySpecifier& Dir) { // Set up the temporary file TempFile.FromDirectory(Dir); // Kludge to make the FSSpec always available FSSpec& temp_file = TempFile.GetSpec(); // Local variable short index; obj_clear(pb); pb.hFileInfo.ioVRefNum= Dir.Get_vRefNum(); pb.hFileInfo.ioNamePtr= temp_file.name; // ZZZ addition bool KeepGoing = true; for(Err= noErr, index=1; count<max && Err==noErr && KeepGoing; index++) { pb.hFileInfo.ioDirID= Dir.Get_parID(); pb.hFileInfo.ioFDirIndex= index; Err= PBGetCatInfo( &pb, false); if(Err == noErr) { if ((pb.hFileInfo.ioFlAttrib & 16) && (flags & _ff_recurse)) { /* Recurse, if you really want to... */ // ZZZ addition: callback on directory change if desired if(directory_change_callback != NULL) KeepGoing = directory_change_callback(TempFile, true, (flags & _ff_callback_with_catinfo) ? &pb : user_data); if(KeepGoing) { // Set up volume info DirectorySpecifier SubDir = Dir; // Change the directory SubDir.Set_parID(pb.dirInfo.ioDrDirID); // Go! Enumerate(SubDir); // Reset the temporary file's directory to what's appropriate here // (it's global to this object) TempFile.FromDirectory(Dir); // ZZZ addition: callback on directory change if desired if(directory_change_callback != NULL) KeepGoing = directory_change_callback(TempFile, false, (flags & _ff_callback_with_catinfo) ? &pb : user_data); } } else { /* Add.. */ if(Type==WILDCARD_TYPE || Type == TempFile.GetType()) { /* Only add if there isn't a callback or it returns true */ switch(search_type) { case _fill_buffer: if(!callback || callback(TempFile, user_data)) { /* Copy it in.. */ buffer[count++] = TempFile; } break; case _callback_only: assert(callback); KeepGoing = callback(TempFile, (flags & _ff_callback_with_catinfo) ? &pb : user_data); break; default: assert(false); break; } } } } else { /* We ran out of files.. */ } } /* If we got a fnfErr, it was because we indexed too far. */ if (Err == fnfErr) Err = noErr; return (Err == noErr); }