home *** CD-ROM | disk | FTP | other *** search
- #include <MacTypes.h>
- #include <FileMgr.h>
- #include <HFS.h>
-
- #include "fix.h"
-
- /* Local prototypes. */
-
- void scan_directory(long dir_id, unsigned char *our_name);
- void hfs_comment_processing(CInfoPBPtr pb, int is_dir);
- void hfs_bundle_processing(CInfoPBPtr pb, int is_dir);
- void hfs_appl_processing(CInfoPBPtr pb, int is_dir);
-
- /* Disk scanning control for an HFS volume. */
-
- void hfs_scan_disk()
- {
- CInfoPBRec pb;
-
- pb.dirInfo.ioCompletion = NIL;
- pb.dirInfo.ioNamePtr = NIL; /* Handle the */
- pb.dirInfo.ioVRefNum = volume_refnum; /* volume's root */
- pb.dirInfo.ioDrDirID = 0; /* directory... */
- pb.dirInfo.ioFDirIndex = 0;
-
- PBGetCatInfo(&pb, 0);
- if (process_comments)
- hfs_comment_processing(&pb,1);
- if (process_bundles)
- hfs_bundle_processing(&pb,1);
- if (process_appls)
- hfs_appl_processing(&pb,1);
-
- scan_directory(0L, NIL); /* Start scan at root... */
- }
-
- /* Scanner for one directory. */
-
- static void scan_directory(dir_id, our_name)
- long dir_id;
- unsigned char *our_name;
- {
- register int index, done, result;
- int is_us;
- CInfoPBRec pb;
- unsigned char name[NAME_SIZE];
-
- set_processing(our_name);
- is_us = 1;
- pb.dirInfo.ioCompletion = NIL;
- pb.dirInfo.ioNamePtr = name;
- pb.dirInfo.ioVRefNum = volume_refnum;
-
- index = 1; done = 0;
- while (!done) {
- SystemTask();
- pb.dirInfo.ioDrDirID = dir_id;
- pb.dirInfo.ioFDirIndex = index++;
- result = PBGetCatInfo(&pb, 0);
- if ((result != noErr) || (pb.dirInfo.ioResult != noErr))
- done = 1;
- else {
- if (pb.dirInfo.ioFlAttrib & 0x10) { /* It's a directory... */
- if (process_comments)
- hfs_comment_processing(&pb, 1);
- if (process_bundles)
- hfs_bundle_processing(&pb, 1);
- if (process_appls)
- hfs_appl_processing(&pb, 1);
- is_us = 0;
- scan_directory(pb.dirInfo.ioDrDirID,name);
- }
- else { /* It's a file... */
- if (!is_us) {
- set_processing(our_name);
- is_us = 1;
- }
- if (process_comments)
- hfs_comment_processing(&pb, 0);
- if (process_bundles)
- hfs_bundle_processing(&pb, 0);
- if (process_appls)
- hfs_appl_processing(&pb, 0);
- }
- }
- }
- }
-
- /* Do comment processing for a file or directory under HFS. */
-
- static void hfs_comment_processing(pb, is_dir)
- CInfoPBPtr pb;
- int is_dir;
- {
- if (is_dir)
- remove_fcmt(pb->dirInfo.ioDrFndrInfo.frComment);
- else
- remove_fcmt(pb->hFileInfo.ioFlXFndrInfo.fdComment);
- }
-
- /* Do bundle processing for a file or directory under HFS. */
-
- static void hfs_bundle_processing(pb,is_dir)
- CInfoPBPtr pb;
- int is_dir;
- {
- if (!is_dir)
- remove_bndl(pb->hFileInfo.ioFlFndrInfo.fdCreator);
- }
-
- /* Do application list processing for a file or dir under HFS. */
-
- static void hfs_appl_processing(pb,is_dir)
- register CInfoPBPtr pb;
- int is_dir;
- {
- if ((!is_dir) &&
- (pb->hFileInfo.ioFlFndrInfo.fdType == 'APPL') &&
- (pb->hFileInfo.ioFlFndrInfo.fdFlags & fHasBundle))
- add_application(pb->hFileInfo.ioFlFndrInfo.fdCreator,
- pb->hFileInfo.ioFlParID,
- pb->hFileInfo.ioNamePtr);
- }
-