The directory access functions provide an API for iterating through the entries within a directory. The fs_opendir()
function initiates this procedure, and each subsequent call to fs_readdir_r()
(until all entries have been examined) returns information about a particular entry in a struct fs_dirent. The fs_closedir()
function releases any file system structures and locks.
The listing below gives an example using the directory access functions to list the files in a directory.
An example result of listing a directory is shown in the figure below.
The second argument fs_readdir_r()
, is a pointer to a struct fs_dirent
, which has two members. The first is Name, which holds the name of the entry; the second is Info, which has file information. For more information about the struct fs_dirent
structure, see FS_DIR_ENTRY (struct fs_dirent).