.import CLOSE
.import readdiskerror, closecmdchannel
- .import __errno, __oserror
+ .import __oserror
.importzp tmp2
.include "errno.inc"
.import addysp, popax
.import scratch, fnparse, fncomplete, fnset
.import opencmdchannel, closecmdchannel, readdiskerror
- .import __errno, __oserror
+ .import __oserror
.import fnunit
.importzp sp, tmp2, tmp3
.import SETLFS, OPEN, CHKIN, BASIN, CLRCH, READST
.import rwcommon
.import popax
- .import __errno, __oserror
+ .import __oserror
.importzp ptr1, ptr2, ptr3, tmp1, tmp2, tmp3
- .include "errno.inc"
.include "fcntl.inc"
.include "cbm.inc"
.include "filedes.inc"
.proc _read
jsr rwcommon ; Pop params, check handle
- bcs invalidfd ; Branch if handle not ok
+ bcs errout ; Invalid handle, errno already set
; Check if the LFN is valid and the file is open for writing
ldx ptr3+1
rts
-; Error entry, file descriptor is invalid
-
-invalidfd:
- lda #EINVAL
- sta __errno
- lda #0
- sta __errno+1
- beq errout
-
; Error entry, file is not open
notopen:
-
.import popax
.importzp ptr1, ptr2, ptr3, tmp2
+ .include "errno.inc"
.include "filedes.inc"
sta ptr3+1 ; Clear ptr3
jsr popax ; Get the handle
- sta tmp2
cpx #$01
- bcs inv
+ bcs invhandle
cmp #MAX_FDS
-inv: rts
+ bcs invhandle
+ sta tmp2
+ rts ; Return with carry clear
+
+invhandle:
+ lda #EINVAL
+ sta __errno
+ lda #0
+ sta __errno+1
+ rts ; Return with carry set
.endproc
.import SETLFS, OPEN, CKOUT, BSOUT, CLRCH
.import rwcommon
- .import __errno, __oserror
+ .import __oserror
.importzp sp, ptr1, ptr2, ptr3
- .include "errno.inc"
.include "fcntl.inc"
.include "cbm.inc"
.include "filedes.inc"
.proc _write
jsr rwcommon ; Pop params, check handle
- bcs invalidfd ; Branch if handle not ok
+ bcs errout ; Invalid handle, errno already set
; Check if the LFN is valid and the file is open for writing
ldx ptr3+1
rts
-; Error entry, file descriptor is invalid
-
-invalidfd:
- lda #EINVAL
- sta __errno
- lda #0
- sta __errno+1
- beq errout
-
; Error entry, file is not open
notopen: