You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

100 lines
2.3 KiB

page
; Library: RCPREN for Z34RCP
; Author: Carson Wilson
; Version: 1.0
; Date: June 15, 1988
;
; Command: REN
; Function: To change the name of an existing file
; Forms:
; LEFTRIGHT false:
; REN <New [du: or dir:]ufn>=<Old [du: or dir:]ufn>
; LEFTRIGHT true:
; REN <Old [du: or dir:]ufn> <New [du: or dir:]ufn>
; LEFTRIGHT and TESTEQ both true:
; Either of the above forms may be used.
ren:
call retsave
call dirchek ; Test bad dirspec
if leftright
call fcbswap ; Exchange command line fcb's
endif
;
; STEP 1: See if old name is ambiguous
;
ld hl,fcb2+1 ; Can't be ambiguous
call ambchk1
;
; STEP 2: Log into user area
;
; If dirspec given at old name, use it
; else use dirspec (or default) given at new name.
ld hl,fcb1 ; Pt to new name
push hl
ld de,fcb2 ; Pt to old name
push de ; Save ptr
ld a,(de) ; Test if dirspec issued
or a ; ..at old name
jr z,ren1 ; No, use user at new name
ld (hl),a ; Stuff drive into new file
ld a,(fcb2+13) ; Yes, log to user area
call setusr ; ..of old name
jr ren2
;
; Use dirspec at new name (none given at old name)
;
ren1:
ld a,(hl) ; Stuff drive of new name
ld (de),a ; ..into old name
call logusr ; Log to user at new name
ren2:
;
; STEP 3: See if old file is R/O
;
pop de ; Restore ptr to old FCB
push de ; Save it again
ld c,17 ; Look for old file
call bdos
inc a
jr z,rnxit
call getsbit ; Match found, get ptr to entry in tbuff
ex de,hl ; Hl pts to entry
inc hl ; Pt to fn
call rotest ; See if file is r/o
jr nz,rnxit1 ; Abort if so
;
; STEP 4: See if new file already exists
; EXTEST performs a number of checks:
; 1) Ambiguity
; 2) R/O
; 3) If file exists and not R/O, permission to delete
;
call extest
jr z,rnxit1 ; R/o or no permission
;
; STEP 5: Exchange file name fields for rename
;
pop de ; Pt to old
pop hl ; Pt to new
push hl ; Save ptr
ld b,12 ; 12 bytes
call iswap1
;
; STEP 6: Rename the file
;
pop de ; Get ptr to FCB
ld c,23 ; Rename
call bdos
inc a ; Set zero flag if error
rnxit:
jp z,noflerr ; EH print no source file message
rnxit1:
jp exit
; End RCPREN.LIB