59 std::ostringstream ss ;
60 static int sequence = 1 ;
67 return 0 == usable( for_creation ) ;
79 if( sorted ) list.
sort() ;
80 list.m_list.swap( out ) ;
85 readType( dir , std::string() ) ;
94 for(
unsigned int i = 0U ; iter.
more() && !iter.
error() ; ++i )
98 if( limit == 0U || m_list.size() < limit )
101 item.m_is_dir = iter.
isDir() ;
104 m_list.push_back( item ) ;
106 if( m_list.size() == limit )
118 more = ! m_list.empty() ;
123 more = m_index < m_list.size() ;
130 return m_list.at(m_index).m_is_dir ;
135 return m_list.at(m_index).m_path ;
140 return m_list.at(m_index).m_name ;
143bool G::DirectoryList::compare(
const Item & a ,
const Item & b )
145 return a.m_name.compare( b.m_name ) < 0 ;
150 std::sort( m_list.begin() , m_list.end() , compare ) ;
A iterator that returns filenames in a directory.
std::string fileName() const
Returns the name of the current item.
bool error() const
Returns true on error. The caller should stop the iteration.
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.
void sort()
Sorts the files lexicographically.
Path filePath() const
Returns the current path.
void readType(const Path &dir, const std::string &suffix, unsigned int limit=0U)
An initialiser that is to be used after default construction.
bool more()
Returns true if more and advances by one.
std::string fileName() const
Returns the current filename.
void readAll(const Path &dir)
An initialiser that is to be used after default construction.
DirectoryList()
Default constructor for an empty list.
bool isDir() const
Returns true if the current item is a directory.
An encapsulation of a file system directory that works with G::DirectoryIterator.
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.
static bool tailMatch(const std::string &in, const std::string &ending)
Returns true if the string has the given ending (or the given ending is empty).
static SystemTime now()
Factory function for the current time.
A directory-entry item for G::DirectoryList.