From d8e6fa61bbcbb86c7bcf287a988f42246f22376f Mon Sep 17 00:00:00 2001 From: Oliver Schmidt Date: Thu, 29 Oct 2020 17:42:36 +0100 Subject: [PATCH] Return NULL on error (or end of directory). --- libsrc/geos-common/file/get1stdirentry.s | 8 ++++++-- libsrc/geos-common/file/getnxtdirentry.s | 10 ++++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/libsrc/geos-common/file/get1stdirentry.s b/libsrc/geos-common/file/get1stdirentry.s index 3b99554eb..381a35c6d 100644 --- a/libsrc/geos-common/file/get1stdirentry.s +++ b/libsrc/geos-common/file/get1stdirentry.s @@ -5,7 +5,7 @@ ; struct filehandle* Get1stDirEntry (void); - .import __oserror + .import __oserror, return0 .export _Get1stDirEntry .include "diskdrv.inc" @@ -14,6 +14,10 @@ _Get1stDirEntry: jsr Get1stDirEntry stx __oserror - lda r5L + txa + beq L0 ; error? + jmp return0 ; return NULL + +L0: lda r5L ldx r5H rts diff --git a/libsrc/geos-common/file/getnxtdirentry.s b/libsrc/geos-common/file/getnxtdirentry.s index 912f48ca4..16a31edcf 100644 --- a/libsrc/geos-common/file/getnxtdirentry.s +++ b/libsrc/geos-common/file/getnxtdirentry.s @@ -5,7 +5,7 @@ ; struct filehandle* GetNxtDirEntry (void); - .import __oserror + .import __oserror, return0 .export _GetNxtDirEntry .include "diskdrv.inc" @@ -14,6 +14,12 @@ _GetNxtDirEntry: jsr GetNxtDirEntry stx __oserror - lda r5L + txa + beq L0 ; error? + tya + beq L0 ; end of dir? + jmp return0 ; return NULL + +L0: lda r5L ldx r5H rts