]> git.sur5r.net Git - cc65/blob - libsrc/cbm/sysrename.s
Made an exec() program-chaining function for the Commodore libraries.
[cc65] / libsrc / cbm / sysrename.s
1 ;
2 ; Ullrich von Bassewitz, 2009-02-22
3 ;
4 ; unsigned char __fastcall__ _sysrename (const char *oldpath, const char *newpath);
5 ;
6
7         .export         __sysrename
8
9         .import         fnparse, fnadd, fnparsename
10         .import         opencmdchannel, closecmdchannel
11         .import         writefndiskcmd, readdiskerror
12         .import         popax
13
14         .import         fncmd, fnunit
15         .importzp       ptr1
16
17
18 ;--------------------------------------------------------------------------
19 ; __sysrename:
20
21 .proc   __sysrename
22
23         jsr     fnparse         ; Parse first filename, pops newpath
24         bne     done
25
26         lda     #'='
27         jsr     fnadd
28
29         jsr     popax
30         sta     ptr1
31         stx     ptr1+1
32         ldy     #0
33         jsr     fnparsename     ; Parse second filename
34         bne     done
35
36         ldx     fnunit
37         jsr     opencmdchannel
38         bne     done
39
40         lda     #'r'            ; Rename command
41         sta     fncmd
42         jsr     writefndiskcmd
43
44 ;       ldx     fnunit
45 ;       jsr     readdiskerror
46
47         pha
48         ldx     fnunit
49         jsr     closecmdchannel
50         pla
51
52 done:   rts
53
54 .endproc
55
56