1;
2;       CPC fcntl Routines
3;       Rename a file
4;
5;       int rename(char *oldname, char *newname)
6;
7;       ----- ----- ----- ----- ----- ----- ----- ----- ----- -----
8;       source:  http://www.cepece.info/amstrad/source/rsxcall.html
9;       ----- ----- ----- ----- ----- ----- ----- ----- ----- -----
10;
11;       $Id: rename.asm,v 1.5 2016-06-19 21:03:22 dom Exp $
12;
13
14        SECTION   code_clib
15        PUBLIC    rename
16        PUBLIC    _rename
17        EXTERN	strlen
18        EXTERN	cpc_rsx
19        EXTERN	bios_msg
20
21        INCLUDE "target/cpc/def/cpcfirm.def"
22
23.rename
24._rename
25
26        pop     bc
27        pop     de
28        pop     hl
29        push    hl
30        push    de
31        push    bc
32
33        push	de
34        ld	(sdb_new_filename+1),hl
35        call	strlen
36        ld	a,l
37        ld	(sdb_new_filename),a
38
39        pop	hl
40        ld	(sdb_old_filename+1),hl
41        call	strlen
42        ld	a,l
43        ld	(sdb_old_filename),a
44
45	;ld	hl,255	; msg disable
46	;push	hl
47	;call	bios_msg
48	;pop	hl
49
50; |REN,"<new filename>,"<old filename>"
51
52	ld	hl,ren_cmd
53	push	hl
54	ld	hl,sdb_old_filename
55	push	hl
56	ld	hl,sdb_new_filename
57	push	hl
58	ld	a,3	; number of parameters
59	call	cpc_rsx
60	pop	bc
61	pop	bc
62	pop	bc
63
64	;ld	hl,0	; msg enable
65	;push	hl
66	;call	bios_msg
67	;pop	hl
68
69	ret
70
71.ren_cmd	defm	"ren",0
72
73;;-------------------------------------------------------------
74;; the string descriptor blocks for the parameters
75
76;; string descriptor block for old filename
77.sdb_old_filename
78defb 0      ;; length of string
79defw 0      ;; address of string
80
81;; string descriptor block for new filename
82.sdb_new_filename
83defb 0      ;; length of string
84defw 0      ;; address of string
85
86;;-------------------------------------------------------------
87
88