std::filesystem::recursive_directory_iterator::disable_recursion_pending (3) - Linux Manuals
std::filesystem::recursive_directory_iterator::disable_recursion_pending: std::filesystem::recursive_directory_iterator::disable_recursion_pending
Command to display std::filesystem::recursive_directory_iterator::disable_recursion_pending
manual in Linux: $ man 3 std::filesystem::recursive_directory_iterator::disable_recursion_pending
NAME
std::filesystem::recursive_directory_iterator::disable_recursion_pending - std::filesystem::recursive_directory_iterator::disable_recursion_pending
Synopsis
void disable_recursion_pending(); (since C++17)
Disables recursion to the currently referred subdirectory, if any.
The call modifies the pending recursion flag on the iterator in such a way that the next time increment is called, the iterator will advance within the current directly even if it is currently referring to a subdirectory that hasn't been visited.
The status of the pending recursion flag can be queried with recursion_pending(), which is false after this call. It is reset back to true after increment, and its initial value is also true.
The behavior is undefined if *this is the end iterator.
Parameters
(none)
Return value
(none)
Exceptions
(none)
Example
// Run this code
#include <fstream>
#include <iostream>
#include <string>
#include <filesystem>
namespace fs = std::filesystem;
int main()
{
fs::create_directories("sandbox/a/b/c");
fs::create_directories("sandbox/a/b/d/e");
std::ofstream("sandbox/a/b/file1.txt");
fs::create_symlink("a", "sandbox/syma");
for(auto i = fs::recursive_directory_iterator("sandbox");
i != fs::recursive_directory_iterator();
++i ) {
std::cout << std::string(i.depth(), ' ') << *i;
if(fs::is_symlink(i->symlink_status()))
std::cout << " -> " << fs::read_symlink(*i);
std::cout << '\n';
// do not descend into "b"
if(i->path().filename() == "b")
i.disable_recursion_pending();
}
fs::remove_all("sandbox");
}
Output:
"sandbox/a"
"sandbox/a/b"
"sandbox/syma" -> "a"
See also
checks whether the recursion is disabled for the current directory
recursion_pending (public member function)
advances to the next entry
increment (public member function)
operator++
Pages related to std::filesystem::recursive_directory_iterator::disable_recursion_pending
- std::filesystem::recursive_directory_iterator::depth (3) - std::filesystem::recursive_directory_iterator::depth
- std::filesystem::recursive_directory_iterator::operator*,std::filesystem::recursive_directory_iterator::operator-> (3) - std::filesystem::recursive_directory_iterator::operator*,std::filesystem::recursive_directory_iterator::operator->
- std::filesystem::recursive_directory_iterator::operator++, (3) - std::filesystem::recursive_directory_iterator::operator++,
- std::filesystem::recursive_directory_iterator::operator++,std::filesystem::recursive_directory_iterator::increment (3) - std::filesystem::recursive_directory_iterator::operator++,std::filesystem::recursive_directory_iterator::increment
- std::filesystem::recursive_directory_iterator::operator= (3) - std::filesystem::recursive_directory_iterator::operator=
- std::filesystem::recursive_directory_iterator::options (3) - std::filesystem::recursive_directory_iterator::options
- std::filesystem::recursive_directory_iterator::pop (3) - std::filesystem::recursive_directory_iterator::pop
- std::filesystem::recursive_directory_iterator::recursion_pending (3) - std::filesystem::recursive_directory_iterator::recursion_pending
- std::filesystem::recursive_directory_iterator::recursive_directory_iterator (3) - std::filesystem::recursive_directory_iterator::recursive_directory_iterator
- std::filesystem::recursive_directory_iterator (3) - std::filesystem::recursive_directory_iterator
- std::filesystem::read_symlink (3) - std::filesystem::read_symlink
- std::filesystem::relative,std::filesystem::proximate (3) - std::filesystem::relative,std::filesystem::proximate
- std::filesystem::remove,std::filesystem::remove_all (3) - std::filesystem::remove,std::filesystem::remove_all
- std::filesystem::rename (3) - std::filesystem::rename
- std::filesystem::resize_file (3) - std::filesystem::resize_file
- std::filesystem::absolute (3) - std::filesystem::absolute
- std::filesystem::begin(directory_iterator),std::filesystem::end(directory_iterator) (3) - std::filesystem::begin(directory_iterator),std::filesystem::end(directory_iterator)
- std::filesystem::begin(recursive_directory_iterator), (3) - std::filesystem::begin(recursive_directory_iterator),
- std::filesystem::begin(recursive_directory_iterator),std::filesystem::end(recursive_directory_iterator) (3) - std::filesystem::begin(recursive_directory_iterator),std::filesystem::end(recursive_directory_iterator)
- std::filesystem::canonical,std::filesystem::weakly_canonical (3) - std::filesystem::canonical,std::filesystem::weakly_canonical
- std::filesystem::copy (3) - std::filesystem::copy