home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / walnut-creek-CDROM / CPM / TURBODSG / DELALL.MAC < prev    next >
Text File  |  2000-06-30  |  6KB  |  282 lines

  1. ; DELALL - delete all (junk) files
  2. ;
  3. ; this program has two modes:
  4. ; 1. NO ARGUMENT:
  5. ;    deletes all *.BAK, *.$$$ and -PRINT-?.??? files on current drive
  6. ; 2. FILENAME ARGUMENT:
  7. ;    deletes all files matching filespec, ignoring drive/user
  8. ;
  9. ; N_O_T_E
  10. ;
  11. ; THIS PROGRAM ACTS ON ALL USER AREAS AT ONCE AND MAY ONLY BE RUN
  12. ; BY A PRIVILEGED USER!
  13. ; DUE TO THE NATURE OF THE PROGRAM, I SPECIFICALLY DISCLAIM *ANYTHING*
  14. ; INCLUDING USABILITY OF THE PROGRAM.  THE AUTHOR MUST NOT BE HELD
  15. ; RESPONSIBLE FOR THE USE OF OR BUGS IN THE PROGRAM.  IT IS THUS THE
  16. ; OPERATOR'S SOLE RESPONSIBILITY TO MAKE SURE THE PROGRAM REALLY
  17. ; WORKS AS CLAIMED.
  18. ; SOURCE IS PROVIDED FOR THE KNOWLEDGEABLE USER TO BE ABLE TO SEE THAT
  19. ; THERE REALLY ARE NO BOOBY TRAPS IN THIS CODE.
  20. ; ESKAY SOFTWARE, S. KLUGER, 7120 SKILLMAN #2104, DALLAS TX 75231
  21. ; PHONE (214) 553-1363
  22. ;
  23. cr    equ    0dh
  24. lf    equ    0ah
  25. sfirst    equ    17
  26. snext    equ    18
  27. delete    equ    19
  28. getdr    equ    25
  29. gsusr    equ    32
  30. priv    equ    12
  31. cfunc    equ    5
  32. tfunc    equ    50h
  33. ;
  34. ; syslib calls are used throughout and denoted by "##"
  35. ;
  36. .request syslib
  37. .z80
  38. ;
  39. ; data section
  40. ;
  41.     dseg
  42. ;
  43. bakfn:    db    '????????BAK'
  44. dolfn:    db    '????????$$$'
  45. prtfn:    db    '-PRINT-????'
  46. cusfn:    db    '           '            ; custom filename
  47. ;
  48. cusflg:    db    0                ; custom file flag
  49. countd:    dw    0                ; count of deleted files
  50. countt:    dw    0                ; count of attempts
  51. ;
  52. delfcb:    db    0,'           ',0,0,0,0        ; delete file fcb
  53.     ds    22
  54. ;
  55. srhfcb:    db    '?'                ; dummy search fcb
  56.     ds    100
  57. stack    equ    $
  58. ;
  59. ; code section
  60. ;
  61.     cseg
  62. ;
  63. start:    ld    sp,stack
  64.     ld    c,priv            ; check if privileged
  65.     call    tfunc
  66.     bit    7,b
  67.     jr    nz,..isp
  68.     call    print##
  69.     cr,lf,lf,7
  70.     'ERROR: non-privileged user',cr,lf,lf,0
  71.     rst    0
  72. ;
  73. ..isp:    ld    hl,5dh            ; point to possible argument
  74.     ld    a,(hl)
  75.     cp    ' '            ; no arg?
  76.     jr    z,..narg
  77.     ld    de,cusfn
  78.     ld    bc,11
  79.     ldir
  80.     ld    a,0ffh
  81.     ld    (cusflg),a
  82. ..narg:    call    print##
  83.     cr,lf
  84.     '                   ---------------------------------'
  85.     cr,lf
  86.     '                  | DELALL v1.10           by ESKAY |'
  87.     cr,lf,0
  88.     ld    a,(cusflg)
  89.     or    a
  90.     jr    z,..na1
  91.     call    print##
  92.     '                  | Deletes specified  files in all |',cr,lf
  93.     '                  |   user areas on current drive   |',cr,lf,0
  94.     jr    ..na2
  95. ;
  96. ..na1:    call    print##
  97.     '                  | Deletes BAK,$$$ and PRINT files |',cr,lf
  98.     '                  | in all user areas on this drive |',cr,lf,0
  99. ..na2:    call    print##
  100.     '                   ---------------------------------'
  101.     cr,lf,lf,0
  102.     ld    hl,5dh            ; point to argument
  103.     ld    a,(cusflg)        ; custom filename?
  104.     or    a
  105.     jp    z,..na3            ;   no, continue normally
  106.     ld    b,11            ; 11 chars to check
  107.     ld    a,'?'            ; see if *.*
  108. ..nacl:    cp    (hl)
  109.     jp    nz,..na3        ; no match, must not be *.*
  110.     inc    hl
  111.     djnz    ..nacl
  112.     call    print
  113.     'WARNING: you are about to erase everything in sight!',cr,lf
  114.     'Is this REALLY what you wish to do? (Say YES or NO) ',0
  115.     ld    a,1            ; set for caps
  116.     call    bbline##        ; get input line
  117.     or    a
  118.     jp    z,exit            ; nothing typed - quit
  119.     ld    a,(hl)
  120.     cp    'Y'            ; first char a "Y"?
  121.     jp    nz,exit            ;   no, get out
  122.     call    print
  123.     cr,lf,lf,0
  124. ..na3:    ld    de,srhfcb        ; point to search fcb
  125.     ld    c,sfirst        ; search first
  126.     call    cfunc            ; turn up disk label
  127. srhlp:    ld    de,srhfcb        ; point to search fcb
  128.     ld    c,snext            ; get next dir entry
  129.     call    cfunc
  130.     cp    0ffh            ; end of directory
  131.     jp    z,exit            ;   yes, quit
  132.     call    moven            ; move name if match and delete
  133.     call    condin##        ; see if console abort
  134.     cp    3
  135.     jp    z,exit
  136.     jr    srhlp            ; get next
  137. ;
  138. ; move name if it matches
  139. ; enter with A=0,1,2,3
  140. ; delete if we can
  141. ;
  142. moven:    ld    c,a            ; move count to c
  143.     ld    a,80h
  144. ..gal:    dec    c
  145.     jp    m,..gad
  146.     add    a,20h
  147.     jr    ..gal
  148. ;
  149. ..gad:    ld    l,a
  150.     ld    h,0            ; hl now points to filename
  151.     ld    a,(hl)            ; get first byte
  152.     cp    0e5h            ; deleted file?
  153.     ret    z            ; yes, return to get next
  154.     ld    a,(cusflg)        ; custom fn specified?
  155.     or    a
  156.     jr    z,..ncs            ; no, skip
  157.     ld    de,cusfn        ; get custom fn
  158.     call    test            ; test against match fn
  159.     call    z,delet            ;   delete if match
  160.     ret
  161. ;
  162. ..ncs:    ld    de,bakfn        ; check .BAK
  163.     call    test
  164.     jr    nz,..nbk
  165.     jp    delet
  166. ;
  167. ..nbk:    ld    de,dolfn        ; check .$$$
  168.     call    test
  169.     jr    nz,..ndo
  170.     jp    delet
  171. ;
  172. ..ndo:    ld    de,prtfn        ; check -PRINT-
  173.     call    test
  174.     ret    nz
  175. ;
  176. ; delete filename at HL
  177. ;
  178. delet:    ld    d,h
  179.     ld    e,l
  180.     push    de            ; save fn pointer
  181.     call    print##
  182.     cr,lf
  183.     'File:  [',0
  184.     ld    a,(hl)            ; get user number
  185.     cp    10            ; 10 or more
  186.     jr    nc,..ov9
  187.     call    print##
  188.     ' ',0
  189. ..ov9:    call    pafdc##            ; print user number
  190.     push    de
  191.     ld    c,getdr
  192.     call    cfunc
  193.     add    a,'A'
  194.     call    cout
  195.     pop    de
  196.     ld    a,':'            ; colon
  197.     call    cout##
  198.     inc    de            ; point to filename
  199.     call    pfn1##            ; print it
  200.     pop    de            ; get fn pointer
  201.     ld    a,(de)            ; get user area
  202.     push    de            ; save fn pointer again
  203.     ld    e,a            ; user into e
  204.     ld    c,gsusr            ; set user
  205.     call    cfunc            ; do it
  206.     ld    hl,(countt)        ; increment total file match count
  207.     inc    hl
  208.     ld    (countt),hl
  209.     pop    de            ; get fn ptr
  210.     ld    hl,9            ; offset to RO tag
  211.     add    hl,de
  212.     bit    7,(hl)            ; RO?
  213.     jr    z,notro
  214.     call    print
  215.     '] not deleted, Read Only',7,0
  216.     ret
  217. ;
  218. notro:    ld    hl,1            ; offset to FIFO tag
  219.     add    hl,de
  220.     bit    7,(hl)
  221.     jr    z,notff
  222.     call    print
  223.     '] not deleted, FIFO',7,0
  224.     ret
  225. ;
  226. notff:    ld    c,delete
  227.     xor    a
  228.     ld    (de),a
  229.     call    cfunc
  230.     or    a
  231.     jr    z,deltok
  232.     call    print
  233.     '] not deleted',7,0
  234.     ret
  235. ;
  236. deltok:    call    print
  237.     '] deleted',0
  238.     ld    hl,(countd)
  239.     inc    hl
  240.     ld    (countd),hl
  241.     ret
  242. ;
  243. ; test filename:
  244. ; HL = pointer to found filename
  245. ; DE = pointer to match filename
  246. ; return with HL intact, Z=match, NZ=no match
  247. ;
  248. test:    push    hl            ; save hl
  249.     inc    hl            ; point to first character
  250.     ld    b,11            ; 11 chars to check
  251. ..tstl:    ld    a,(de)            ; get match byte
  252.     cp    '?'            ; a wildcard character?
  253.     jr    z,..autm        ;   yes, automatic match
  254.     ld    c,(hl)            ; get target byte
  255.     res    7,c            ; strip high bit
  256.     cp    c            ; matching target?
  257.     jr    nz,..noma        ;   no match!
  258. ..autm:    inc    hl
  259.     inc    de
  260.     djnz    ..tstl
  261. ..noma:    pop    hl            ; all set
  262.     ret                ;   to ret    
  263. ;
  264. exit:    call    print##
  265.     cr,lf,lf
  266.     '[END OF EXECUTION - DELETED ',0
  267.     ld    hl,(countd)
  268.     call    phlfdc##
  269.     call    print##
  270.     ' OF ',0
  271.     ld    hl,(countt)
  272.     call    phlfdc##
  273.     call    print##
  274.     ' FILES]',cr,lf,lf,0
  275.     rst    0
  276.     end
  277. 
  278.     call    print
  279.     '] not deleted, FIFO',7,0
  280.     ret
  281. ;
  282. notff:    ld