home *** CD-ROM | disk | FTP | other *** search
/ Phoenix CD 2.0 / Phoenix_CD.cdr / 11a / cover20.zip / COSCAN.ASM < prev    next >
Assembly Source File  |  1991-01-21  |  4KB  |  160 lines

  1.     PAGE    ,132
  2.     TITLE    COSCAN  -  Diskette contents list  -  Scan Directory
  3.     COMMENT        * Version 1.0  -  June 1983
  4.             (PER Dr. Dobbs Journal, January, 1984, #87)
  5.             (Dan Daetwyler "Sorted Diskette Directory for
  6.                  the IBM PC")
  7.  
  8.         Version 2.0       Bruce F. Cameron
  9.                   Cincinnati  OH 
  10.  
  11.            February 25, 1985
  12.  
  13.     Counts hidden files
  14.     Grouped sort (i.e. all COM files first etc.)
  15.     Includes Volume Label and Directory (if not root)
  16.     Lists Subdirectory names
  17.     Free space up to 100M (hard disk)  *
  18. ;
  19. ;
  20.     PAGE    82
  21. ;
  22. CODE    SEGMENT    PARA PUBLIC 'CODE'
  23.     ASSUME    CS:CODE, DS:CODE
  24. ;
  25.     EXTRN    RELOC:BYTE, PNTR:WORD, SRCE:BYTE
  26. ;
  27.     PUBLIC    HIDNFL
  28. HIDNFL    DB    3 DUP (0)        ; Working buffer for hidden file count
  29.     PUBLIC    EXTND, ATRB
  30. EXTND    DB    0FFH,0,0,0,0,0        ; Dummy FCB for file find (extended)
  31. ATRB    DB    0FFH            ; File attribute byte
  32.     DB    0,'???????????'        ; Dummy FCB for file find (normal)
  33.     DB    24 DUP (?)
  34. ;
  35.     PUBLIC    SCAN
  36. SCAN    PROC    NEAR
  37.     MOV    DI,OFFSET PNTR
  38.     XOR    AX,AX
  39.     MOV    CX,120
  40.     REP    STOSW            ; Clear pointer table
  41.     MOV    BX,OFFSET PNTR        ; BX to pointer list
  42.     MOV    DI,OFFSET SRCE        ; DI to file name stack
  43.     XOR    CX,CX
  44.     MOV    DX,OFFSET EXTND        ; Search FCB
  45.     CMP    ATRB,010H        ; Subdirectory search?
  46.     JE    SHORT MAIN
  47.     MOV    ATRB,2            ; Set for hidden files
  48.     JMP    SHORT MAIN
  49. SYS:    MOV    ATRB,4            ; Set for system files
  50.     JMP    SHORT MAIN
  51. IBM:    MOV    ATRB,6            ; Set for IBMBIO, IBMDOS,...
  52.     JMP    SHORT MAIN
  53. FIL:    MOV    HIDNFL,CL        ; Save hidden file count
  54.     XOR    CX,CX
  55.     MOV    ATRB,0            ; Set for regular files
  56. MAIN:    MOV    AH,11H
  57.     INT    21H            ; Get first search entry
  58.     JMP    SHORT INNER
  59. LOOP:    MOV    DX,OFFSET EXTND
  60.     MOV    AH,12H
  61.     INT    21H            ; Get next entry
  62. INNER:    OR    AL,AL
  63.     JNZ    DONE
  64.     MOV    SI,88H            ; File name in DTA
  65.     CMP    BYTE PTR [SI],'.'
  66.     JE    LOOP            ; Directory entry, ignore
  67.     CALL    SAVE            ; File name to stack
  68.     MOV    AL,ATRB            ; Fetch attribute of search
  69.     MOV    SI,93H            ; Point to DTA attribute field
  70.     CMP    AL,BYTE PTR [SI]
  71.     JE    TYPMCH            ; Is requested type, process
  72.     XOR    AL,20H            ; Flip archive bit (test type both ways)
  73.     CMP    AL,BYTE PTR [SI]
  74.     JE    TYPMCH
  75.     XOR    AL,1            ; Flip read-only bit
  76.     CMP    AL,BYTE PTR [SI]
  77.     JE    TYPMCH
  78.     XOR    AL,20H            ; Reflip archive, test all combos
  79.     CMP    AL,BYTE PTR [SI]
  80.     JNE    LOOP            ; Don't count if not requested type
  81. TYPMCH:    INC    CX            ; Count entries
  82.     JMP    LOOP
  83. DONE:    CMP    ATRB,0            ; If zero, all file types checked
  84.     JZ    ALLFL
  85.     CMP    ATRB,4
  86.     JB    SYS            ; =2, next to system
  87.     JE    IBM            ; =4, next to IBM...
  88.     CMP    ATRB,6
  89.     JE    FIL            ; =6, next to regular
  90. ALLFL:    MOV    ATRB,0FFH        ; Reset to initial value
  91.     RET                ; Returns count in CX
  92. SCAN    ENDP
  93. ;
  94. SAVE    PROC    NEAR
  95.     CMP    ATRB,010H        ; Subdirectory search?
  96.     JE    DIREN
  97.     CMP    ATRB,0
  98.     JNZ    PASS            ; Hidden file count, no name save
  99.     JMP    SHORT ENTRY        ; Put normal files into stack
  100. DIREN:    MOV    SI,93H            ; Attribute field
  101.     TEST    BYTE PTR [SI],010H
  102.     JZ    PASS            ; Not subdirectory, no save
  103. ENTRY:    PUSH    CX
  104.     MOV    WORD PTR [BX],DI    ; Save pointer to entry stack
  105.     ADD    BX,2            ;   and step pointer table
  106.     PUSH    DI            ; Save address for ordering character
  107.     INC    DI            ; Step to start of name
  108.     MOV    SI,88H            ; Point to DTA file name
  109.     MOV    CX,8
  110. SVLP:    MOV    AL,BYTE PTR [SI]
  111.     CMP    AL,' '
  112.     JZ    NMDNE            ; End of name
  113.     MOV    BYTE PTR [DI],AL
  114.     INC    SI
  115.     INC    DI
  116.     LOOP    SVLP
  117. NMDNE:    MOV    SI,90H            ; Point to DTA type field
  118.     JMP    TESTRE            ; Check if relocation requested
  119. STOTYP:    CMP    BYTE PTR [SI],' '
  120.     JZ    ALLDNE            ; No file type
  121.     MOV    BYTE PTR [DI],'.'
  122.     INC    DI
  123.     MOV    CX,3
  124.     REP    MOVSB            ; Move type field to stack
  125. ALLDNE:    MOV    BYTE PTR [DI],0        ; Mark end of string
  126.     INC    DI
  127.     MOV    SI,0A4H            ; Point to file size
  128.     MOV    CX,4
  129.     REP    MOVSB            ;   and save in stack
  130.     POP    AX            ; `Ordering' character
  131.     POP    BP            ; Location for same (PUSH from DI)
  132.     MOV    [BP],AL            ; Put at start of string
  133.     POP    CX
  134. PASS:    RET
  135. ;
  136. TESTRE:    PUSH    DI
  137.     MOV    AL,0A0H            ; Default order high
  138.     MOV    DI,OFFSET RELOC
  139. TLP:    CMP    BYTE PTR [DI],0        ; End of reorder table
  140.     JE    NOMTCH
  141.     PUSH    DI            ; Save start of string in table
  142.     PUSH    SI            ;    and FCB location pointer
  143.     MOV    CX,3
  144.     REPE    CMPSB            ; File extension to table
  145.     POP    SI
  146.     POP    DI
  147.     JE    MATCH
  148.     ADD    DI,4            ; Point to next entry
  149.     JMP    TLP
  150. MATCH:    MOV    AL,[DI+3]        ; Reorder character to AL
  151. NOMTCH:    POP    DI            ; Restore to value at entry
  152.     PUSH    AX            ; Reorder char to stack
  153.     JMP    STOTYP
  154. ;
  155. SAVE    ENDP
  156. ;
  157. CODE    ENDS
  158. ;
  159.     END
  160. V