It would be nice to have a way to make sure a directory_iterator does not open a symlink to a directory; maybe by adding a function to get a directory_entry structure of the root directory, or by adding another constructor. Currently it is possible to do this:
fs::path root("root");
fs::recursive_directory_iterator iter;
if (!fs::is_symlink(root)) {
iter = fs::recursive_directory_iterator(root, fs::symlink_option::no_recurse);
}
However, there is a race condition here: After having checked that root is not a symlink, the world may change and the constructor may open a symlink.