35 class DirectoryIteratorImp ;
37 class DirectoryIterator ;
58 int usable(
bool for_creating_files =
false )
const ;
69 bool valid(
bool for_creating_files =
false )
const ;
72 bool writeable(
const std::string & probe_filename =
tmp() )
const ;
80 static std::string
tmp() ;
138 std::unique_ptr<DirectoryIteratorImp> m_imp ;
152 bool m_is_dir{
false} ;
153 bool m_is_link{
false} ;
156 bool operator<(
const Item & )
const noexcept ;
163 std::size_t readAll(
const Path & dir ) ;
167 std::size_t readType(
const Path & dir ,
string_view suffix ,
unsigned int limit = 0U ) ;
172 std::size_t readDirectories(
const Path & dir ,
unsigned int limit = 0U ) ;
192 static void readAll(
const Path & dir , std::vector<Item> & out ) ;
201 unsigned int m_index{0U} ;
202 std::vector<Item> m_list ;
205inline bool G::DirectoryList::Item::operator<(
const Item & other )
const noexcept
207 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.
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.