From aad17a6f057dc57424c010c0d832e1f49592f044 Mon Sep 17 00:00:00 2001 From: Greg King Date: Thu, 29 Oct 2020 17:54:56 -0400 Subject: [PATCH] Made two GEOS directory functions return NULL if they can't give a valid entry. --- doc/geos.sgml | 19 ++++++++++--------- libsrc/geos-common/file/get1stdirentry.s | 12 ++++++------ libsrc/geos-common/file/getnxtdirentry.s | 14 +++++++------- 3 files changed, 23 insertions(+), 22 deletions(-) diff --git a/doc/geos.sgml b/doc/geos.sgml index a10ade5d5..11ff9c534 100644 --- a/doc/geos.sgml +++ b/doc/geos.sgml @@ -858,20 +858,21 @@ The functions described here are common for SEQ and VLIR structures.

-These two functions are best suited for scanning the whole directory for particular files. Note that -the returned filehandles describe all file slots in the directory - even those with deleted files. -The return value can be obtained by casting both sides to geos/gdisk.h). The current +directory track and sector numbers are in FindFile

-This function scans the whole directory for the given filename. It returns either 0 (success) or 5 -(FILE_NOT_FOUND, defined in geos/gdisk.h), or any other fatal disk read error. After a successful +FindFTypes

diff --git a/libsrc/geos-common/file/get1stdirentry.s b/libsrc/geos-common/file/get1stdirentry.s index 381a35c6d..f0ad59388 100644 --- a/libsrc/geos-common/file/get1stdirentry.s +++ b/libsrc/geos-common/file/get1stdirentry.s @@ -1,7 +1,7 @@ ; -; Maciej 'YTM/Alliance' Witkowiak +; 1999-10-26, Maciej 'YTM/Alliance' Witkowiak +; 2020-10-29, Greg King ; -; 26.10.99 ; struct filehandle* Get1stDirEntry (void); @@ -15,9 +15,9 @@ _Get1stDirEntry: jsr Get1stDirEntry stx __oserror txa - beq L0 ; error? - jmp return0 ; return NULL - -L0: lda r5L + bne L1 ; jump if disk error + lda r5L ldx r5H rts + +L1: jmp return0 ; return NULL if not valid entry diff --git a/libsrc/geos-common/file/getnxtdirentry.s b/libsrc/geos-common/file/getnxtdirentry.s index 16a31edcf..e8ccbf3a2 100644 --- a/libsrc/geos-common/file/getnxtdirentry.s +++ b/libsrc/geos-common/file/getnxtdirentry.s @@ -1,7 +1,7 @@ ; -; Maciej 'YTM/Alliance' Witkowiak +; 1999-10-26, Maciej 'YTM/Alliance' Witkowiak +; 2020-10-29, Greg King ; -; 26.10.99 ; struct filehandle* GetNxtDirEntry (void); @@ -15,11 +15,11 @@ _GetNxtDirEntry: jsr GetNxtDirEntry stx __oserror txa - beq L0 ; error? + bne L1 ; jump if disk error tya - beq L0 ; end of dir? - jmp return0 ; return NULL - -L0: lda r5L + bne L1 ; jump when no more entries + lda r5L ldx r5H rts + +L1: jmp return0 ; return NULL if not valid entry