aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/clickhouse/src/Disks/ObjectStorages/StaticDirectoryIterator.h
blob: 891bdb688f00ab333274091f2eae8d34a630a4ca (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#pragma once

#include <Disks/DirectoryIterator.h>
#include <vector>
#include <filesystem>
#include <string>

namespace DB
{

class StaticDirectoryIterator final : public IDirectoryIterator
{
public:
    explicit StaticDirectoryIterator(std::vector<std::filesystem::path> && dir_file_paths_)
        : dir_file_paths(std::move(dir_file_paths_))
        , iter(dir_file_paths.begin())
    {}

    void next() override { ++iter; }

    bool isValid() const override { return iter != dir_file_paths.end(); }

    std::string path() const override { return iter->string(); }

    std::string name() const override { return iter->filename(); }

private:
    std::vector<std::filesystem::path> dir_file_paths;
    std::vector<std::filesystem::path>::iterator iter;
};

}