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
/
ZCPR33
/
S-Z
/
VFILER43.LBR
/
VFCMDS6.LZB
/
VFCMDS6.LIB
Wrap
Text File
|
2000-06-30
|
7KB
|
293 lines
;===========================================================================
;
; VFCMDS6.Z80 - Move, Delete, Rename Files (M, D, R)
;
;===========================================================================
; COMMAND: 'M' Move files
move:
call ermsg
db 'Move File',0
xor a
ld (mflag),a ; Not mass operation
ld (first$m),a ; Ask destination
call copy ; Ask where
jr fdel0 ; Delete source, quit
; * * * COMMAND: D
fdel:
xor a ; Set no mass operation
ld (mflag),a
call ringfcb ; Get filename into s$fcb
call delprmpt ; Prompt for deletion
jp nz,loop ; If rejected, back to command loop
fdel0:
call delete ; Delete file
; Was Deletion Done? Abort if Not
ld a,(delcode) ; 0=not done
or a
jp z,loop ; Abort if not
; Check for deletion of All local files
ld hl,(locend) ; Move in end
ld de,-eltsiz
add hl,de
ld de,(locbeg) ; Erased all local files?
call cmpdehl
jr nz,fdel1 ; No - continue
ld (locend),hl ; Yes - set new local end.
jp cmdloop ; Start on first screen again.
; Check for deletion with full screen of files remaining.
fdel1:
ld de,(ringend) ; Last screen of files?
call cmpdehl
jr nz,fdel4 ; No. redisplay with new last file.
; Check for Deletion of last file in ring.
push hl ; Save new local end.
ld de,(ringpos) ; Deleted file was last file in ring?
call cmpdehl
jr nz,fdel2 ; No? rebuild shorter display.
; Last file in ring deleted - move back one position
ld de,-eltsiz ; Reset position to new end.
add hl,de
ld (ringpos),hl
call psn$back ; Back up cursor by one file
; Erase file at previous last file position
fdel2:
ld hl,(curat) ; Save current cursor position
ld (scurat),hl
call cur$last ; Position to previous last file.
ld b,entsiz ; Blank it
ld a,' '
fdel3:
call cout
djnz fdel3
ld hl,(scurat) ; Restore current cursor position
ld (curat),hl
pop hl ; Set new local end.
ld (locend),hl
; Redisplay files starting at RINGPOS
fdel4:
call erclr ; Clear error message line.
jp runsh5 ; Redisplay current files
; DELETE - Delete filename at RINGPOS
delete:
xor a
ld (delcode),a ; Set deletion not done
call ringfcb ; Get file name
ld a,(mflag) ; Mass operation?
or a ; 0=no
jr z,del1 ; Do delete
ld a,(massop) ; Mass move?
cp 'M'
jr z,del1 ; If so, perform as single delete
; Test for Verify on Mass Delete
ld a,(mdflg) ; Verify?
cp 'V'
jr nz,del1 ; Delete without verify
; Group Delete with Verify
; - Verify file deletion
; - Delete only if Approved
call delprmpt ; Prompt for deletion of file
ret nz ; Abort if not approved
; Display File Deletion Message
del1:
call cprmpt
db 'Deleting ',0
call prfns
; Delete File in S$FCB
del2:
ld hl,s$fcb ; Check file R/W status
call attrib
ret z ; Abort if R/O and delete not approved
ld de,s$fcb ; Point at delete 'fcb'
ld c,erase ; Erase function
call bdos
inc a
jr nz,delcl0 ; Branch if delete succeeded
fnf$msg:
call fnf1 ; Show error message
jp loop
delcl0: ld a,0ffh
ld (delcode),a ; Set deletion done
ld a,(mflag)
or a
ret nz ; If mass operation, quit now
; Close up erased position
ld hl,(ringpos) ; Prepare move up pointers
push hl
ld de,eltsiz ; Eltsiz bytes/entry
add hl,de ; De = 'to' location
pop de ; Hl = 'from' location
; Move ELTSIZ-byte ring entries from HL to DE
movup: ex de,hl ; Hl=dest
push hl ; Check if at end
ld hl,(ringend) ; Get old end pointer
call cmpdehl ; Check against current end location
pop hl
ex de,hl ; De=dest
jr z,movdone ; Must be at end of ring
ld b,eltsiz ; One name size
call movec ; Move one name up
jr movup ; Go check end parameters
; Move Complete
movdone:
ld (ringend),de ; Set new ring end if all moved
ld hl,(ringcnt) ; One less element in array.
dec hl
ld (ringcnt),hl
ret
; Prompt for deletion of file
delprmpt:
call erclr ; Clear the error line
call cprmpt
db 'Delete ',0
call prfns ; Print file name in s$fcb
call vprint
db ' (Y/N)? ',0
call keyin
push af
call atcmd ; Clear the command line
pop af
cp ctrlc
jp z,loop ; Restart if Control C
cp 'Y'
ret
; * * * COMMAND: R
; Set-up to rename file at cursor position
; scan keyboard buffer and move filename to destination FCB (DFCB)
rename:
ld hl,(ringpos) ; Point to the file in the ring
ld de,9 ; Offset to R/O byte
add hl,de ; Point to it
ld a,128 ; Set bit 7 of A
cp (hl) ; Set carry if R/O
jr nc,renam0 ; File is R/W
call atcmd ; Cursor to command prompt
ld hl,(ringpos) ; Get ring position
inc hl ; Point to name
call prfnskip ; Print file name
call vprint
db ' is R/O. Rename anyway (Y/N)? ',bel,0
call keyin
cp 'Y'
jp nz,loop
renam0:
call erclr ; Clear error line
call cprmpt ; New name prompt
db 'Rename File to: ',0
ld de,d$fcb ; Pt to fcb to fill
call filename ; Get file name & init fcb.
ld hl,d$fcb+1 ; Check for any wild cards -- none permitted
ld b,11 ; 11 bytes
wildchk:
ld a,(hl) ; Get char
inc hl ; Pt to next
cp '?' ; Wild?
jr z,wildfnd
djnz wildchk
ld de,d$fcb ; Search to see if this file exists
ld c,srchf ; Search first function
call bdos
inc a ; 0ffh --> 00h if file not found
jr z,renam1 ; To rename, if duplicate doesn't exists.
call ermsg ; Announce the situation
db 'File Exists',0
jr renam0 ; Try again?
renam1:
ld hl,d$fcb ; -> file id filled in by filename
ld de,d$fcb+16 ; -> to new file id field of fcb
ld b,12 ; Amount to move
call movec
ld hl,(ringpos) ; Move name from ring to rename 'fcb'
ld de,d$fcb ; Place to move name
ld b,12 ; Amount to move
call movea ; Moves name and not attributes
ld de,d$fcb
ld c,attr
call bdos ; Clear attributes on disk
ld de,d$fcb ; Rename 'fcb' location
ld c,ren ; Rename function
call bdos
ld hl,(ringpos)
ld de,9
add hl,de ; Point to R/O attribute
ld a,128
and (hl)
jr z,renam2 ; All Attributes are reset
ld hl,d$fcb+25
or (hl)
ld (hl),a ; Set R/O attribute
ld de,d$fcb+16 ; New name with attributes
ld c,attr
call bdos ; Set the attributes
renam2:
ld hl,(ringpos)
ex de,hl ; To DE
ld hl,d$fcb+16 ; New name with attributes
ld b,12
call movec ; Copy into ring
jp runsh5 ; Quit
; wild char found in file name -- error
wildfnd:
call ermsg
db 'AFN NOT Allowed',bel,0
jp renam0 ; Try again