mirror of
https://github.com/cc65/cc65.git
synced 2025-01-26 17:36:57 +00:00
added closeallfiles: close all files at program exit
git-svn-id: svn://svn.cc65.org/cc65/trunk@1892 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
parent
d25ea2001b
commit
0c50092c3e
@ -1,5 +1,5 @@
|
||||
;
|
||||
; Christian Groessler, May-2002
|
||||
; Christian Groessler, Jan-2003
|
||||
;
|
||||
; int open(const char *name,int flags,...);
|
||||
;
|
||||
@ -7,7 +7,12 @@
|
||||
.include "atari.inc"
|
||||
.include "fcntl.inc"
|
||||
.include "errno.inc"
|
||||
.include "fd.inc"
|
||||
|
||||
.export _open
|
||||
.destructor closeallfiles, 17
|
||||
|
||||
.import _close
|
||||
.import clriocb
|
||||
.import fddecusage,newfd
|
||||
.import findfreeiocb
|
||||
@ -47,7 +52,6 @@ iocbok: stx tmp4
|
||||
jsr clriocb ; init with zero
|
||||
ldy #1
|
||||
jsr ldaxysp ; get mode
|
||||
;brk
|
||||
ldx tmp4
|
||||
pha
|
||||
and #O_APPEND
|
||||
@ -149,3 +153,20 @@ ok: lda tmp2 ; get fd
|
||||
rts
|
||||
|
||||
.endproc
|
||||
|
||||
|
||||
; closeallfiles: Close all files opened by the program.
|
||||
|
||||
.proc closeallfiles
|
||||
|
||||
lda #MAX_FD_INDEX-1
|
||||
loop: ldx #0
|
||||
pha
|
||||
jsr _close
|
||||
pla
|
||||
clc
|
||||
sbc #0
|
||||
bpl loop
|
||||
rts
|
||||
|
||||
.endproc
|
||||
|
Loading…
x
Reference in New Issue
Block a user