home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / lambda / soundpot / p / z33rcp02.lbr / RCPPROT.LZB / RCPPROT.LIB
Encoding:
Text File  |  1993-10-25  |  2.4 KB  |  115 lines

  1.     page
  2.  
  3. ; RCP-PROT.Z80
  4.  
  5. ;Section 5F
  6. ;Command: PROT
  7. ;Function:  To set the attributes of a file (R/O and SYS)
  8. ;
  9. ;Form:
  10. ;    PROT afn RSI
  11. ;If either R or S are omitted, the file is made R/W or DIR, resp;
  12. ;R and S may be in any order.  If I is present, Inspection is enabled.
  13.  
  14. att:
  15.     call    retsave
  16.     xor    a        ; Set no inspect
  17.     ld    (inspect),a
  18.     ld    hl,0        ; Set r/o and sys attributes off
  19.     ld    de,fcb2+1    ; Pt to attributes
  20.     ld    b,3        ; 3 chars max
  21. att1:
  22.     ld    a,(de)        ; Get char
  23.     inc    de        ; Pt to next
  24.     cp    'I'        ; Inspect?
  25.     jr    z,atti
  26.     cp    'R'        ; Set r/o?
  27.     jr    z,attr
  28.     cp    'S'        ; Set sys?
  29.     jr    z,atts
  30. att2:
  31.     djnz    att1
  32.     jr    att3
  33. atti:
  34.     ld    (inspect),a    ; Set flag
  35.     jr    att2
  36. attr:
  37.     ld    h,80h        ; Set r/o bit
  38.     jr    att2
  39. atts:
  40.     ld    l,80h        ; Set sys bit
  41.     jr    att2
  42. att3:
  43.     ld    (fatt),hl    ; Save file attributes
  44.     ld    a,1        ; Select dir and sys files
  45.     call    getdir        ; Load directory
  46.     jp    z,prfnf        ; No file error
  47.     jr    att5
  48. att4:
  49.     ld    hl,(nxtfile)    ; Pt to next file
  50.     ld    a,(hl)        ; End of list?
  51.     or    a
  52.     jp    z,exit
  53.     call    crlf        ; New line
  54. att5:
  55.     call    break        ; Check for possible abort
  56.     push    hl        ; Save ptr to current file
  57.     call    prfn        ; Print its name
  58.     ld    (nxtfile),hl    ; Save ptr to next file
  59.     call    print
  60.     db    ' Set to R','/'+80h
  61.     ld    hl,(fatt)    ; Get attributes
  62.     ld    c,'W'        ; Assume r/w
  63.     ld    a,h        ; Get r/o bit
  64.     or    a
  65.     jr    z,att6
  66.     ld    c,'O'        ; Set r/o
  67. att6:
  68.     ld    a,c        ; Get char
  69.     call    conout
  70.     ld    a,l        ; Get sys flag
  71.     or    a        ; Set flag
  72.     jr    z,att7
  73.     call    print
  74.     db    ' and SY','S'+80h
  75. att7:
  76. inspect    equ    $+1        ; Ptr for in-the-code modification
  77.     ld    a,0        ; Get inspect flag
  78.     or    a        ; Z=no
  79.     pop    hl        ; Get ptr to current file
  80.     jr    z,att8
  81.     call    eraq1        ; Ask for y/n
  82.     jr    nz,att4        ; Advance to next file if not y
  83. att8:
  84.     ld    de,fcb1+1    ; Copy into fcb1
  85.     ld    b,11        ; 11 bytes
  86.     call    blkmov
  87. fatt    equ    $+1        ; Ptr for in-the-code modification
  88.     ld    hl,0        ; Get attributes
  89.     dec    de        ; Pt to sys byte
  90.     dec    de
  91.     ld    a,l        ; Get sys flag
  92.     call    attset        ; Set attribute correctly
  93.     dec    de        ; Pt to r/o byte
  94.     ld    a,h        ; Get r/o flag
  95.     call    attset
  96.     ld    de,fcb1        ; Pt to fcb
  97.     ld    c,30        ; Set attributes
  98.     call    bdos
  99.     jr    att4
  100. attset:
  101.     or    a        ; 0=clear attribute
  102.     jr    z,attst1
  103.     ld    a,(de)        ; Get byte
  104.     or    80h        ; Set attribute
  105.     ld    (de),a
  106.     ret
  107. attst1:
  108.     ld    a,(de)        ; Get byte
  109.     and    7fh        ; Clear attribute
  110.     ld    (de),a
  111.     ret
  112. ;
  113. ; End RCP-PROT.Z80
  114.  
  115.