home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / sigm / vol147 / eraq.a86 < prev    next >
Encoding:
Text File  |  1984-04-29  |  2.0 KB  |  142 lines

  1.     title    'ERAQ - Selective file erase'
  2.  
  3. ;    Supplied by NEC Information Systems Australia
  4. ;    Extracted from SIG/M volume 43
  5.  
  6. CR    EQU    13
  7. LF    EQU    10
  8. ESC    EQU    27
  9. TFCB    EQU    5CH
  10.  
  11.     org    100h
  12.  
  13. ERAQ:    mov    dx,TFCB
  14.     mov    cl,17        ;Search first
  15.     CALL    BDOS
  16.     cmp    al,255
  17.     jnz    FILFND
  18.     mov    dx,offset NFMSG
  19.     call    OUTBUF
  20.     mov    cl,0
  21.     jmp    BDOS
  22. OUTBUF:    mov    cl,9        ;Print string
  23.     jmp    BDOS
  24. FILFND:    mov    bx,offset NAMBUF
  25.     PUSH    bx
  26. NXTFIL:
  27.     mov    cl,5
  28.     shl    al,cl
  29.     add    al,81h
  30.     mov    ah,0
  31.     mov    si,ax
  32.     POP    di
  33.     mov    cx,11
  34.     rep movs al,al
  35.     PUSH    di
  36.     mov    cl,18        ;Search next
  37.     mov    dx,tfcb
  38.     CALL    BDOS
  39.     cmp    al,255
  40.     jnz    NXTFIL
  41.     POP    bx
  42.     mov    byte ptr [bx],80H    ;End of list indicator
  43.     mov    bx,offset NAMBUF
  44. DELCHK:    mov    NBPOS,bx
  45.                 ;Output name
  46.     mov    cx,8
  47. NXTCR2: mov    al,[bx]
  48.     AND    al,7FH
  49.     cmp    al,' '
  50.     jz    ENDNAM    ;End of name
  51.     PUSH    bx
  52.     PUSH    cx
  53.     CALL    CONOUT
  54.     POP    cx
  55.     POP    bx
  56.     INC    bx
  57.     loop    NXTCR2
  58. ENDNAM:    mov    ch,0
  59.     ADD    bx,cx
  60.     PUSH    bx
  61.     mov    al,[bx]
  62.     AND    al,7FH
  63.     cmp    al,' '
  64.     jz    ENDTYP        ;No filetype
  65.     mov    al,'.'
  66.     CALL    CONOUT
  67.                 ;Output type
  68.     mov    cx,3
  69.     POP    bx
  70.     PUSH    bx
  71. NXTCR3: mov    al,[bx]
  72.     AND    al,7FH
  73.     cmp    al,' '
  74.     jz    ENDTYP        ;End of type
  75.     PUSH    bx
  76.     PUSH    cx
  77.     CALL    CONOUT
  78.     POP    cx
  79.     POP    bx
  80.     INC    bx
  81.     loop    NXTCR3
  82. ENDTYP: mov    dx,offset DFMSG1    ;Output rest of the message
  83.     CALL    OUTBUF
  84.     POP    bx
  85.     test    byte ptr [bx],80h
  86.     jz    NOTR_O        ;Check for file R/O
  87.     mov    dx,offset DFMSG2
  88.     CALL    OUTBUF
  89. NOTR_O: mov    dx,offset DFMSG3
  90.     CALL    OUTBUF
  91.     mov    cl,1        ;Console input
  92.     CALL    BDOS
  93.     cmp    al,ESC
  94.     jnz    $+3
  95.     RET
  96.     AND    al,5FH        ;Convert lowercase to uppercase
  97.     cmp    al,'Y'
  98.     jnz    NXTCHK
  99.     mov    si,NBPOS
  100.     mov    di,TFCB+1
  101.     mov    cx,11
  102.     rep movs al,al
  103.     mov    bx,TFCB+9
  104.     test    byte ptr [bx],80h
  105.     jz    NTR_O
  106.     and    byte ptr [bx],7fh
  107.     mov    dx,TFCB
  108.     mov    cl,30        ;Set file attributes
  109.     CALL    BDOS
  110. NTR_O:    mov    dx,TFCB
  111.     mov    cl,19        ;Delete file
  112.     CALL    BDOS
  113. NXTCHK:    mov    al,CR
  114.     CALL    CONOUT
  115.     mov    al,LF
  116.     CALL    CONOUT
  117.     mov    bx,NBPOS
  118.     add    bx,11
  119.     test    byte ptr [bx],80h
  120.     mov    cl,0
  121.     jnz    bdos
  122.     jmp    DELCHK
  123.  
  124. CONOUT: mov    dl,al
  125.     mov    cl,2        ;Console output
  126. BDOS:
  127.     push    es
  128.     int    224
  129.     pop    es
  130.     ret
  131.  
  132. NFMSG    db    'File(s) not found$'
  133. DFMSG1    db    ' exists$'
  134. DFMSG2    db    ' and is R/O$'
  135. DFMSG3    db    '.  Do you want it deleted?$'
  136.  
  137. NBPOS    dw    0
  138. NAMBUF    rs    64*64
  139.     db    0
  140.  
  141.     END
  142.