;
; Ullrich von Bassewitz, 16.11.2002
;
-; int open (const char* name, int flags, ...); /* May take a mode argument */
-;
-; Be sure to keep the value priority of closeallfiles lower than that of
-; closeallstreams (which is the high level C file I/O counterpart and must be
-; called before closeallfiles).
+; int open (const char* name, int flags, ...); /* May take a mode argument */
.export _open
.destructor closeallfiles, 5
- .import SETLFS, OPEN, CLOSE
.import addysp, popax
.import scratch, fnparse, fnaddmode, fncomplete, fnset
.import opencmdchannel, closecmdchannel, readdiskerror
.include "errno.inc"
.include "fcntl.inc"
.include "filedes.inc"
+ .include "cbm.inc"
;--------------------------------------------------------------------------
; Throw away any additional parameters passed through the ellipsis
- dey ; Parm count < 4 shouldn't be needed to be...
- dey ; ...checked (it generates a c compiler warning)
+ dey ; Parm count < 4 shouldn't be needed to be...
+ dey ; ...checked (it generates a c compiler warning)
+ dey
dey
- dey
- beq parmok ; Branch if parameter count ok
- jsr addysp ; Fix stack, throw away unused parameters
+ beq parmok ; Branch if parameter count ok
+ jsr addysp ; Fix stack, throw away unused parameters
; Parameters ok. Pop the flags and save them into tmp3
; Invalid open mode
-einval: lda #EINVAL
+ lda #EINVAL
; Error entry. Sets _errno, clears _oserror, returns -1
oserror:jmp __mappederrno
-
; Read bit is set. Add an 'r' to the name
-doread: ldy fnisfile ; File or directory?
- beq isdir ; Don't add ,R for directory
- lda #'r'
+doread: lda #'r'
jsr fnaddmode ; Add the mode to the name
-isdir: lda #LFN_READ
+ lda #LFN_READ
bne common ; Branch always
; If O_TRUNC is set, scratch the file, but ignore any errors
.endproc
-
+