home *** CD-ROM | disk | FTP | other *** search
-
- ; FCensus: HFS/MSF file census routine from Feb '86 MacTutor
- ; Provides info on each file on a volume, whether MFS or HFS.
-
- ; Proc FCensus(vRefNum:integer; DirID:longint; Inspector:ProcPtr);
-
- ; vRefNum: volume reference number (or drive number) of volume
-
- ; dirID: ID of directory to start. Root dir = 2.
-
- ; Inspector: user-supplied function
- ; MyInspector(ParamBlock:ParmBlkPtr; dirID:longint):boolean
- ; ParamBlock is a GetFileInfo block
- ; dirID is the ID of the file's directory
- ; If returned value = True, search ends.
- ; If returned value = False, search continues.
-
- Include Traps.D
- Include SysEquX.D
- Include FSEqu.D
- Include SysErr.D
-
- .MACRO _TFSCORE
- IF '%1' <> ''
- LEA %1,A0
- ENDIF
- IF '%3' = ''
- DC.W $A200+%2
- ENDIF
- IF '%3' = 'REGS'
- DC.W $A300+%2
- ENDIF
- IF '%3' = 'ASYNC'
- DC.W $A600+%2
- ENDIF
- IF '%3' = 'SYS'
- DC.W $A600+%2
- ENDIF
- IF '%3' = 'IMMED'
- DC.W $A200+%2
- ENDIF
- .ENDM
-
-
- .MACRO _GetCatInfo
- MOVEQ #9,D0
- _TFSCore %1,96,%2
- .ENDM
-
-
- ; A6 offsets
- OldA6 set 0
- ReturnAddr set OldA6+4
- Inspec set ReturnAddr+4
- DirID set Inspec+4
- vRefNum set DirID+4
- ArgsSz set vRefNum+2-Inspec
- ;
- ParmBlk set OldA6-ioHVQElSize ; local parm block
- NameStr set ParmBlk-256 ; Str255 buffer
- Index set NameStr-2 ; directory index
-
- XRef FCensus
-
- FCensus
- Link a6,#Index
- clr.l -(sp) ; sentinel for end of DirID list
- NextDir
- clr Index(a6) ; init index = 0
- NextFile
- lea ParmBlk(a6),a0 ; a0 = parm block pointer
- clr.l ioCompletion(a0)
- clr.l ioFileName(a0)
- move vRefNum(a6),ioVRefNum(a0) ; set volume
- move.l dirID(a6),ioDirID(a0) ; set directory ID
- lea NameStr(a6),a1 ; a1 = name string buffer pointer
- move.l a1,ioFileName(a0) ; set file name pointer
- addq #1,Index(a6) ; advance index
- move Index(a6),ioFDirIndex(a0) ; set index
- tst FSFCBLen ; HFS running?
- bmi.s @0 ; branch if not
- _GetCatInfo
- bra.s @1
- @0 _GetFileInfo ; MFS, get partial story
- @1 beq.s NodeKind ; no error, check things out
- cmp #fnfErr,d0 ; end of directory?
- bne.s FCExit ; no, unexpected problem
- move.l (sp)+,dirID(a6) ; pop next directory off stack
- bne.s NextDir ; branch if there is one
- bra.s FCExit ; branch if there isn't one
- NodeKind
- btst #ioDirFlg,ioFlAttrib(a0) ; directory?
- beq.s CallInspec ; a file, call Inspector
- move.l ioDirID(a0),-(sp) ; directory, push on stack
- bra.s NextFile ; look for next file
- CallInspec
- clr -(sp) ; for returned value
- pea ParmBlk(a6) ; param block for inspector
- move.l dirID(a6),-(sp) ; pass dirID
- move.l Inspec(a6),a0 ; address of user function
- jsr (a0) ; call inspector
- tst.b (sp)+ ; time to quit?
- beq.s NextFile ; no, keep going
- FCExit
- unlk a6
- move.l (sp)+,a0 ; a0 = return address
- lea ArgsSz(sp),sp ; pop arguments
- jmp (a0) ; return
- dc.b 'FCensus'
- .align 2
-