Enumerating the content of a directory
So far in this chapter, we took a look at many of the functionalities provided by the filesystem
library, such as working with paths, performing operations with files and directories (creating, moving, renaming, deleting, and so on), and querying or modifying properties. Another useful functionality when working with the filesystem is to iterate through the content of a directory. The file library provides two directory iterators, one called directory_iterator
that iterates the content of a directory, and one called recursive_directory_iterator
 that iterates recursively the content of a directory and its subdirectories. In this recipe, we will see how to use these.
Getting ready
In this recipe, we will work with filesystem paths and will check the properties of a filesystem object. Therefore, it is recommended that you first read the recipes Working with filesystem paths and Checking the properties of an existing file or directory.
For this recipe, we...