2001-12-09 21:53:11 +00:00
|
|
|
;
|
|
|
|
; Christian Groessler, Dec-2001
|
|
|
|
;
|
|
|
|
; int remove (const char* name);
|
|
|
|
;
|
|
|
|
|
|
|
|
.include "atari.inc"
|
|
|
|
.include "../common/errno.inc"
|
|
|
|
.import findfreeiocb,incsp2,__do_oserror
|
|
|
|
.import popax,__oserror,__seterrno
|
|
|
|
.importzp tmp1
|
|
|
|
.ifdef UCASE_FILENAME
|
2001-12-27 20:37:52 +00:00
|
|
|
.importzp tmp3
|
|
|
|
.import addysp
|
|
|
|
.import ucase_fn
|
2001-12-09 21:53:11 +00:00
|
|
|
.endif
|
|
|
|
.export _remove
|
|
|
|
|
|
|
|
.proc _remove
|
|
|
|
|
|
|
|
jsr findfreeiocb
|
|
|
|
beq iocbok ; we found one
|
|
|
|
|
|
|
|
jsr incsp2 ; discard stack argument
|
|
|
|
lda #<EMFILE ; "too many open files"
|
|
|
|
ldx #>EMFILE
|
|
|
|
seterr: jsr __seterrno
|
|
|
|
lda #$FF
|
|
|
|
tax
|
|
|
|
rts ; return -1
|
|
|
|
|
|
|
|
iocbok: ;stx tmp1 ; remember IOCB index
|
|
|
|
txa
|
|
|
|
pha
|
|
|
|
jsr popax
|
|
|
|
|
|
|
|
.ifdef UCASE_FILENAME
|
|
|
|
|
2001-12-27 20:37:52 +00:00
|
|
|
jsr ucase_fn
|
|
|
|
bcc ucok1
|
|
|
|
lda #<EINVAL ; file name is too long
|
2001-12-09 21:53:11 +00:00
|
|
|
ldx #>EINVAL
|
|
|
|
jmp seterr
|
2001-12-27 20:37:52 +00:00
|
|
|
ucok1:
|
2001-12-09 21:53:11 +00:00
|
|
|
|
|
|
|
.endif ; defined UCASE_FILENAME
|
|
|
|
|
|
|
|
;ldy tmp1
|
|
|
|
sta tmp1
|
|
|
|
pla
|
|
|
|
tay
|
|
|
|
lda tmp1
|
|
|
|
sty tmp1
|
|
|
|
sta ICBAL,y
|
|
|
|
txa
|
|
|
|
sta ICBAH,y
|
|
|
|
ldx tmp1
|
|
|
|
lda #DELETE
|
|
|
|
sta ICCOM,x
|
|
|
|
lda #0
|
|
|
|
sta ICAX1,x
|
|
|
|
sta ICAX2,x
|
|
|
|
sta ICBLL,x
|
|
|
|
sta ICBLH,x
|
|
|
|
jsr CIOV
|
|
|
|
|
|
|
|
.ifdef UCASE_FILENAME
|
|
|
|
tya
|
|
|
|
pha
|
|
|
|
ldy tmp3 ; get size
|
|
|
|
jsr addysp ; free used space on the stack
|
|
|
|
pla
|
|
|
|
tay
|
|
|
|
.endif ; defined UCASE_FILENAME
|
|
|
|
|
|
|
|
bmi cioerr
|
|
|
|
|
|
|
|
ldx #0
|
|
|
|
stx __oserror
|
|
|
|
txa
|
|
|
|
rts
|
|
|
|
|
|
|
|
cioerr: jmp __do_oserror
|
|
|
|
|
|
|
|
.endproc ; _remove
|