Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

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.

Figure 10-2 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 Figure 4-1.Listing 10-5 Directory listing output (example)

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 section D-5 “FS_DIR_ENTRY (struct fs_dirent)”.