Sending the readdir message to a
CfsDirectoryDescriptor instance causes the instance to answer a new
CfsDirectoryEntry instance representing the next directory entry matching the specified pattern and type. A
CfsDirectoryEntry instance understands the same messages as a
CfsStat instance, plus the
dName message, which answers the name of the file represented by the directory entry as a string. See
Testing existence and obtaining other file properties for a description of the messages understood by a
CfsStat instance.
The readdir: message is identical in behavior to
readdir, except that instead of creating a new
CfsDirectoryEntry instance, it stores the directory information in the
CfsDirectoryEntry instance supplied as an argument. This technique provides better performance than creating and discarding a directory entry for each item in the directory. An example follows:
Do not use readdirName followed by
CfsStat>>
stat: to get file information, because this is never faster than using
readdir or
readdir:, and forces some platforms to search the directory twice. Using
readdir: is the most efficient technique if more than the file names are needed.
For maximum efficiency when using readdirName, ensure that the
mode argument is the inclusive-OR of
FREG,
FDIR and
FSPECIAL. Specifying that all file types are to be matched eliminates an operating system call to determine the file type, which would otherwise be needed on some platforms.