Line data Source code
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 37 : Directory(const std::string& directory_path) : directory_path_(directory_path) {} 21 : 22 37 : DirectoryIteratorImpl begin() { return {directory_path_}; } 23 : 24 37 : DirectoryIteratorImpl end() { return {}; } 25 : 26 : private: 27 : const std::string directory_path_; 28 : }; 29 : 30 : } // namespace Filesystem 31 : } // namespace Envoy