Added the POSIX functions opendir() and closedir().

git-svn-id: svn://svn.cc65.org/cc65/trunk@5666 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
uz
2012-05-30 19:37:57 +00:00
parent 6952703d69
commit 08b4ed1035
4 changed files with 140 additions and 6 deletions

53
libsrc/cbm/closedir.s Normal file
View File

@@ -0,0 +1,53 @@
;
; Ullrich von Bassewitz, 2012-05-30
;
; Based on C code by Groepaz
;
; int __fastcall__ closedir(DIR *dir);
;
.include "dir.inc"
.include "zeropage.inc"
.import _close, _free
.proc _closedir
sta ptr1
stx ptr1+1
; Load dir->fd
ldy #DIR::fd+1
lda (ptr1),y
tax
dey
lda (ptr1),y
; Close the file
jsr _close
; Save the error code
pha
txa
pha
; Free the memory block
lda ptr1
ldx ptr1+1
jsr _free
; Return the error code from close()
pla
tax
pla
rts
.endproc