1
0
mirror of https://github.com/cc65/cc65.git synced 2024-12-23 04:30:10 +00:00

Made two GEOS directory functions return NULL if they can't give a valid entry.

This commit is contained in:
Greg King 2020-10-29 17:54:56 -04:00
parent d8e6fa61bb
commit aad17a6f05
3 changed files with 23 additions and 22 deletions

View File

@ -858,20 +858,21 @@ The functions described here are common for SEQ and VLIR structures.
<p>
<tt/struct filehandle *GetNxtDirEntry (void)/
<p>
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 <tt/unsigned/ - as in the <tt/SetNextFree/
function or read directly after a call to those two functions from <tt/r5/. The current sector number
is in <tt/r1/ and the sector data itself is in <tt/diskBlkBuf/.
Those 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 is <tt/NULL/ if there are no more slots, or if there was a disk error. The
<tt/_oserror/ variable is non-zero if it was a disk error (see <tt>geos/gdisk.h</tt>). The current
directory track and sector numbers are in <tt/r1L/ and <tt/r1H/. The sector data itself is in
<tt/diskBlkBuf/.
<sect3>FindFile
<p>
<tt/char FindFile (char *fName)/
<p>
This function scans the whole directory for the given filename. It returns either 0 (success) or 5
(FILE_NOT_FOUND, defined in <tt/gdisk.h/) or any other fatal disk read error. After a successful
<tt/FindFile/ you will have <tt/struct filehandle/ at <tt/dirEntryBuf/ filled with the file's data and
other registers set as described in <tt/GetNxtDirEntry/.
This function scans the whole directory for the given filename. It returns either 0 (success), 5
(FILE_NOT_FOUND, defined in <tt>geos/gdisk.h</tt>), or any other fatal disk read error. After a successful
<tt/FindFile()/, you will have <tt/struct filehandle/ at <tt/dirEntryBuf/ filled with the file's data, and
other registers set as described in <tt/GetNxtDirEntry()/.
<sect3>FindFTypes
<p>

View File

@ -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

View File

@ -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