The Directory Entry & Directory Iteration
In this lesson, we'll see different ways of iterating over a path.
We'll cover the following...
While the path
class represent files or paths that exist or not, we also have another object that is more concrete: it’s directory_entry
object. This object points to existing files and directories, and it’s usually obtained by iterating using filesystem iterators.
What’s more, implementations are encouraged to cache the additional file attributes. That way there can be fewer system calls.
Traversing a Path with Directory Iterators
You can traverse a path using two available iterators:
directory_iterator
- iterates in a single directory, input iteratorrecursive_directory_iterator
- iterates recursively, input