36 class DirectoryIteratorImp ;
38 class DirectoryIterator ;
59 int usable(
bool for_creating_files =
false )
const ;
70 bool valid(
bool for_creating_files =
false )
const ;
73 bool writeable(
const std::string & probe_filename =
tmp() )
const ;
81 static std::string
tmp() ;
140 std::unique_ptr<DirectoryIteratorImp> m_imp ;
154 bool m_is_dir {
false} ;
155 bool m_is_link {
false} ;
158 bool operator<(
const Item & )
const noexcept ;
165 std::size_t readAll(
const Path & dir ) ;
169 std::size_t readType(
const Path & dir , std::string_view suffix ,
unsigned int limit = 0U ) ;
174 std::size_t readDirectories(
const Path & dir ,
unsigned int limit = 0U ) ;
177 bool empty() const noexcept ;
195 static
void readAll( const
Path & dir ,
std::vector<
Item> & out ) ;
203 bool m_first {
true} ;
204 unsigned int m_index {0U} ;
205 std::vector<Item> m_list ;
208inline bool G::DirectoryList::Item::operator<(
const Item & other )
const noexcept
210 return m_name < other.m_name ;
A iterator that returns unsorted filenames in a directory.
DirectoryIterator(const Directory &dir)
Constructor taking a directory reference.
std::string fileName() const
Returns the name of the current item.
bool error() const
Returns true on error. The caller should stop the iteration.
std::string sizeString() const
Returns the file size as a decimal string.
bool isLink() const
Returns true if the current item is a symlink.
~DirectoryIterator()
Destructor.
bool isDir() const
Returns true if the current item is a directory or a symlink to a directory.
bool more()
Returns true if more and advances by one.
Path filePath() const
Returns the path of the current item.
A iterator similar to G::DirectoryIterator but doing all file i/o in one go and providing a sorted re...
DirectoryList()
Default constructor for an empty list.
An encapsulation of a file system directory that works with G::DirectoryIterator.
int usable(bool for_creating_files=false) const
Returns zero if the object represents a valid directory with permissions that dont disallow reading o...
bool writeable(const std::string &probe_filename=tmp()) const
Tries to create and then delete an empty test file in the directory.
static std::string tmp()
A convenience function for constructing a filename for writeable().
Path path() const
Returns the directory's path, as passed in to the ctor.
bool valid(bool for_creating_files=false) const
Returns true iff usable() is zero.
Directory()
Default constructor for the current directory.
A Path object represents a file system path.
A class like c++17's std::string_view.
A directory-entry item for G::DirectoryList.