Returning directory entries

In the example for the io_read() function above, we saw how to return data. As mentioned in the description of the io_read() function (in the "Alphabetical listing of Connect and I/O functions"), the io_read() function may return directory entries as well. Since this isn't something that everyone will want to do, I discuss it here.

First of all, let's look at why and when you'd want to return directory entries rather than raw data from io_read().

If you discretely manifest entries in the pathname space, and those entries are not marked with the _RESMGR_FLAG_DIR, then you won't have to return directory entries in io_read(). If you think about this from a "filesystem" perspective, you're effectively creating "file" types of objects. If, on the other hand, you do specify _RESMGR_FLAG_DIR, then you're creating a "directory" type of object. Nobody other than you knows what the contents of that directory are, so you have to be the one to supply this data. That's exactly why you'd return directory entries from your io_read() handler.