Namespaces
Variants

std::experimental::filesystem:: recursive_directory_iterator

From cppreference.net
헤더 파일에 정의됨 <experimental/filesystem>
class recursive_directory_iterator ;
(filesystem TS)

recursive_directory_iterator 는 디렉토리의 LegacyInputIterator 로, 디렉토리의 directory_entry 요소들을 순회하고, 재귀적으로 모든 하위 디렉토리의 항목들을 순회합니다. 반복 순서는 명시되지 않았으나, 각 디렉토리 항목은 한 번만 방문됩니다.

기본적으로 심볼릭 링크는 따라가지 않지만, 생성 시 디렉토리 옵션 follow_directory_symlink 을 지정하면 활성화할 수 있습니다.

특수 경로명 dot dot-dot 은 건너뜁니다.

만약 recursive_directory_iterator 가 최상위 디렉토리의 마지막 디렉토리 엔트리를 지나 진행되면, 이는 기본 생성된 반복자(종료 반복자라고도 함)와 동일하게 됩니다. 두 개의 종료 반복자는 항상 동일하며, 종료 반복자를 역참조하거나 증가시키는 것은 정의되지 않은 동작입니다.

디렉토리 트리에 파일이나 디렉토리가 추가되거나 삭제된 후 재귀적 디렉토리 이터레이터가 생성되면, 해당 변경 사항이 이터레이터를 통해 관찰될지 여부는 명시되어 있지 않습니다.

디렉토리 구조에 순환(cycle)이 포함된 경우, end iterator에 도달하지 못할 수 있습니다.

목차

멤버 타입

멤버 타입 정의
value_type filesystem::directory_entry
difference_type std::ptrdiff_t
pointer const filesystem::directory_entry*
reference const filesystem::directory_entry&
iterator_category std::input_iterator_tag

멤버 함수

recursive_directory_iterator를 생성합니다
(public member function)
(destructor)
기본 소멸자
(public member function)
Observers
가리키는 항목에 접근합니다
(public member function)
현재 반복에 영향을 미치는 활성 옵션을 반환합니다
(public member function)
현재 재귀 깊이를 반환합니다
(public member function)
현재 디렉토리에 대해 재귀가 비활성화되었는지 확인합니다
(public member function)
Modifiers
내용을 할당합니다
(public member function)
다음 항목으로 진행합니다
(public member function)
디렉토리 계층 구조에서 한 단계 위로 반복자를 이동합니다
(public member function)
다음 증가까지 재귀를 비활성화합니다
(public member function)

비멤버 함수

범위 기반 for 루프 지원
(함수)

또한, operator== operator!= LegacyInputIterator 요구사항에 따라 멤버 또는 비멤버 형태로 제공됩니다.

참고 사항

recursive_directory_iterator 는 일반적으로 참조 카운팅된 포인터 ( LegacyInputIterator 의 얕은 복사 의미론을 충족시키기 위해)를 구현 객체에 보유하며, 이 구현 객체는 다음을 포함합니다:

예제

#include <experimental/filesystem>
#include <fstream>
#include <iostream>
namespace fs = std::experimental::filesystem;
int main()
{
    fs::create_directories("sandbox/a/b");
    std::ofstream("sandbox/file1.txt");
    fs::create_symlink("a", "sandbox/syma");
    for (const fs::directory_entry& entry : fs::recursive_directory_iterator("sandbox"))
        std::cout << entry << '\n';
    fs::remove_all("sandbox");
}

가능한 출력:

"sandbox/a"
"sandbox/a/b"
"sandbox/file1.txt"
"sandbox/syma"

참고 항목

디렉토리 내용에 대한 반복자
(클래스)
디렉토리 항목
(클래스)
디렉토리 내용 순회를 위한 옵션들
(열거형)