Coverage Report

Created: 2024-09-19 09:45

/proc/self/cwd/source/common/filesystem/directory.h
Line
Count
Source
1
#pragma once
2
3
#include <string>
4
5
#include "envoy/filesystem/filesystem.h"
6
7
#include "source/common/filesystem/directory_iterator_impl.h"
8
9
namespace Envoy {
10
namespace Filesystem {
11
12
// This class does not do any validation of input data. Do not use with untrusted inputs.
13
//
14
// DirectoryIteratorImpl will fail silently and act like an empty iterator in case of
15
// error opening the directory, and will silently skip files that can't be stat'ed. Check
16
// DirectoryIteratorImpl::status() after initialization and after each increment if
17
// silent failure is not the desired behavior.
18
class Directory {
19
public:
20
7.40k
  Directory(const std::string& directory_path) : directory_path_(directory_path) {}
21
22
7.40k
  DirectoryIteratorImpl begin() { return {directory_path_}; }
23
24
8.13k
  DirectoryIteratorImpl end() { return {}; }
25
26
private:
27
  const std::string directory_path_;
28
};
29
30
} // namespace Filesystem
31
} // namespace Envoy