Post by firstname.lastname@example.org
Just out of interest, what exactly would cause read% to return zero whilst
next% <> -1 I.e there are still entries to read... Curiosity...
It depends entirely on the implementation of the underlying file system which
may not be FileCore.
You should also not assume that the value in F4 increases by one each time
the information for a single file is read. Some applications come unstuck by
making this assumption, which does not hold true for FAT32FS, for example.
To give you an example of why a filing system might return no entries, let me
introduce you to the CP/M disc format, for which I wrote CPMFS. The CP/M
format was a predecessor of MSDOS and is the origin of the 8 + 3 (name +
extension) style of filename that persisted until Windows 95.
The directory on the disc is held in a block of a number of consecutive
sectors. Each directory entry is 32 bytes long. The first 16 bytes
contains a byte that can indicate the file is deleted, the filename, and a
directory entry count. The following 16 bytes point to the sectors on the
disc where the file is found.
The way I implemented CPMFS, R4 corresponds to the directory entry to read
next, so when you enter with R4 = 0 it reads the first entry. Suppose you
ask for four to be read each time. On exit R4 will equal 4, then 8, then 12,
and eventually will be set to -1 when there are no more to read.
But it's possible that all the first four directory entries are for deleted
files, in which case no results will be returned. Also, if a file is larger
than 16K it will require more than one directory entry to record the
allocated sectors, so any of the directory entries that handle the overflow
will not be reported when reading the files via OS_GBPB.
At least, that's one possible implementation. It's certainly how I handled
what R4 meant, but it may be that I just looped round until I had read the
number of objects requested in R3, and the exit value in R4 would have gone
up by more than four in these cases. I can't remember.
FAT32FS also implements R4 in a similar way. This means you cannot safely
take 1 off R4 to step back by 1 in the directory listing.
Another reason for returning zero in R3 might be if the filing system is
waiting for a network device to respond and has had to time out to keep the