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

  1.     page
  2.  
  3. ; RCP-REN.Z80
  4.  
  5. ;Section 5E
  6. ;Command: REN
  7. ;Function:  To change the name of an existing file
  8. ;Forms:
  9. ;    REN <New ufn>=<Old ufn> Perform function
  10. ;
  11. ren:
  12. ;
  13. ; CHECK FOR WHEEL APPROVAL IF OPTION ENABLED
  14. ;
  15.  
  16.     call    retsave
  17. ;
  18. ;
  19. ; STEP 1:  CHECK FOR FILE 2 BEING AMBIGUOUS
  20. ;
  21.     ld    hl,fcb2+1    ; Can't be ambiguous
  22.     call    ambchk1
  23. ;
  24. ; STEP 2:  LOG INTO USER AREA
  25. ;
  26.     call    logusr        ; Log into user area of fcb1
  27. ;
  28. ; STEP 3:  SEE IF OLD FILE IS R/O
  29. ;
  30.     ld    hl,fcb1        ; Pt to 1st fcb
  31.     push    hl
  32.     ld    de,fcb2        ; Pt to 2nd file
  33.     push    de        ; Save ptr
  34.     ld    a,(hl)        ; Get 1st's drive
  35.     ld    (de),a        ; Stuff into second fcb
  36.     ld    c,17        ; Look for file
  37.     call    bdos
  38.     inc    a
  39.     jp    z,prfnf
  40.     call    getsbit        ; Get ptr to entry in tbuff
  41.     ex    de,hl        ; Hl pts to entry
  42.     inc    hl        ; Pt to fn
  43.     call    rotest        ; See if file is r/o
  44.     jp    nz,exit
  45. ;
  46. ; STEP 4:  SEE IF NEW FILE ALREADY EXISTS
  47. ;   EXTEST PERFORMS A NUMBER OF CHECKS:
  48. ;     1) AMBIGUITY
  49. ;     2) R/O
  50. ;     3) IF FILE EXISTS AND NOT R/O, PERMISSION TO DELETE
  51. ;
  52.     call    extest
  53.     jp    z,exit        ; R/o or no permission
  54. ;
  55. ; STEP 5:  EXCHANGE FILE NAME FIELDS FOR RENAME
  56. ;
  57.     pop    de        ; Pt to old
  58.     pop    hl        ; Pt to new
  59.     push    hl        ; Save ptr
  60.     ld    b,12        ; 12 bytes
  61.     call    iswap1
  62. ;
  63. ; STEP 6:  RENAME THE FILE
  64. ;
  65.     pop    de        ; Get ptr to fcb
  66.     ld    c,23        ; Rename
  67.     call    bdos
  68.     inc    a        ; Set zero flag if error
  69.     jp    z,prfnf        ; Print no source file message
  70.     jp    exit
  71. ;
  72. ;
  73. ; End RCP-REN.Z80
  74.  
  75.