home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Phoenix CD 2.0
/
Phoenix_CD.cdr
/
11a
/
cover20.zip
/
COSCAN.ASM
< prev
next >
Wrap
Assembly Source File
|
1991-01-21
|
4KB
|
160 lines
PAGE ,132
TITLE COSCAN - Diskette contents list - Scan Directory
COMMENT * Version 1.0 - June 1983
(PER Dr. Dobbs Journal, January, 1984, #87)
(Dan Daetwyler "Sorted Diskette Directory for
the IBM PC")
Version 2.0 Bruce F. Cameron
Cincinnati OH
February 25, 1985
Counts hidden files
Grouped sort (i.e. all COM files first etc.)
Includes Volume Label and Directory (if not root)
Lists Subdirectory names
Free space up to 100M (hard disk) *
;
;
PAGE 82
;
CODE SEGMENT PARA PUBLIC 'CODE'
ASSUME CS:CODE, DS:CODE
;
EXTRN RELOC:BYTE, PNTR:WORD, SRCE:BYTE
;
PUBLIC HIDNFL
HIDNFL DB 3 DUP (0) ; Working buffer for hidden file count
PUBLIC EXTND, ATRB
EXTND DB 0FFH,0,0,0,0,0 ; Dummy FCB for file find (extended)
ATRB DB 0FFH ; File attribute byte
DB 0,'???????????' ; Dummy FCB for file find (normal)
DB 24 DUP (?)
;
PUBLIC SCAN
SCAN PROC NEAR
MOV DI,OFFSET PNTR
XOR AX,AX
MOV CX,120
REP STOSW ; Clear pointer table
MOV BX,OFFSET PNTR ; BX to pointer list
MOV DI,OFFSET SRCE ; DI to file name stack
XOR CX,CX
MOV DX,OFFSET EXTND ; Search FCB
CMP ATRB,010H ; Subdirectory search?
JE SHORT MAIN
MOV ATRB,2 ; Set for hidden files
JMP SHORT MAIN
SYS: MOV ATRB,4 ; Set for system files
JMP SHORT MAIN
IBM: MOV ATRB,6 ; Set for IBMBIO, IBMDOS,...
JMP SHORT MAIN
FIL: MOV HIDNFL,CL ; Save hidden file count
XOR CX,CX
MOV ATRB,0 ; Set for regular files
MAIN: MOV AH,11H
INT 21H ; Get first search entry
JMP SHORT INNER
LOOP: MOV DX,OFFSET EXTND
MOV AH,12H
INT 21H ; Get next entry
INNER: OR AL,AL
JNZ DONE
MOV SI,88H ; File name in DTA
CMP BYTE PTR [SI],'.'
JE LOOP ; Directory entry, ignore
CALL SAVE ; File name to stack
MOV AL,ATRB ; Fetch attribute of search
MOV SI,93H ; Point to DTA attribute field
CMP AL,BYTE PTR [SI]
JE TYPMCH ; Is requested type, process
XOR AL,20H ; Flip archive bit (test type both ways)
CMP AL,BYTE PTR [SI]
JE TYPMCH
XOR AL,1 ; Flip read-only bit
CMP AL,BYTE PTR [SI]
JE TYPMCH
XOR AL,20H ; Reflip archive, test all combos
CMP AL,BYTE PTR [SI]
JNE LOOP ; Don't count if not requested type
TYPMCH: INC CX ; Count entries
JMP LOOP
DONE: CMP ATRB,0 ; If zero, all file types checked
JZ ALLFL
CMP ATRB,4
JB SYS ; =2, next to system
JE IBM ; =4, next to IBM...
CMP ATRB,6
JE FIL ; =6, next to regular
ALLFL: MOV ATRB,0FFH ; Reset to initial value
RET ; Returns count in CX
SCAN ENDP
;
SAVE PROC NEAR
CMP ATRB,010H ; Subdirectory search?
JE DIREN
CMP ATRB,0
JNZ PASS ; Hidden file count, no name save
JMP SHORT ENTRY ; Put normal files into stack
DIREN: MOV SI,93H ; Attribute field
TEST BYTE PTR [SI],010H
JZ PASS ; Not subdirectory, no save
ENTRY: PUSH CX
MOV WORD PTR [BX],DI ; Save pointer to entry stack
ADD BX,2 ; and step pointer table
PUSH DI ; Save address for ordering character
INC DI ; Step to start of name
MOV SI,88H ; Point to DTA file name
MOV CX,8
SVLP: MOV AL,BYTE PTR [SI]
CMP AL,' '
JZ NMDNE ; End of name
MOV BYTE PTR [DI],AL
INC SI
INC DI
LOOP SVLP
NMDNE: MOV SI,90H ; Point to DTA type field
JMP TESTRE ; Check if relocation requested
STOTYP: CMP BYTE PTR [SI],' '
JZ ALLDNE ; No file type
MOV BYTE PTR [DI],'.'
INC DI
MOV CX,3
REP MOVSB ; Move type field to stack
ALLDNE: MOV BYTE PTR [DI],0 ; Mark end of string
INC DI
MOV SI,0A4H ; Point to file size
MOV CX,4
REP MOVSB ; and save in stack
POP AX ; `Ordering' character
POP BP ; Location for same (PUSH from DI)
MOV [BP],AL ; Put at start of string
POP CX
PASS: RET
;
TESTRE: PUSH DI
MOV AL,0A0H ; Default order high
MOV DI,OFFSET RELOC
TLP: CMP BYTE PTR [DI],0 ; End of reorder table
JE NOMTCH
PUSH DI ; Save start of string in table
PUSH SI ; and FCB location pointer
MOV CX,3
REPE CMPSB ; File extension to table
POP SI
POP DI
JE MATCH
ADD DI,4 ; Point to next entry
JMP TLP
MATCH: MOV AL,[DI+3] ; Reorder character to AL
NOMTCH: POP DI ; Restore to value at entry
PUSH AX ; Reorder char to stack
JMP STOTYP
;
SAVE ENDP
;
CODE ENDS
;
END
V