VideoTools
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
G::DirectoryList Class Reference

A Directory iterator with the same kind of interface as G::DirectoryIterator, but doing all file i/o in one go. More...

#include <gdirectory.h>

Classes

struct  Item
 A directory-entry item for G::DirectoryList. More...
 

Public Member Functions

 DirectoryList ()
 Default constructor for an empty list. More...
 
void readAll (const Path &dir)
 An initialiser that is to be used after default construction. More...
 
void readType (const Path &dir, const std::string &suffix, unsigned int limit=0U)
 An initialiser that is to be used after default construction. More...
 
bool more ()
 Returns true if more and advances by one.
 
bool isDir () const
 Returns true if the current item is a directory.
 
Path filePath () const
 Returns the current path.
 
std::string fileName () const
 Returns the current filename.
 
void sort ()
 Sorts the files lexicographically.
 

Static Public Member Functions

static void readAll (const Path &dir, std::vector< Item > &out, bool sorted)
 A static overload returning by reference a collection of Items. More...
 

Detailed Description

A Directory iterator with the same kind of interface as G::DirectoryIterator, but doing all file i/o in one go.

This is useful, compared to DirectoryIterator, when temporarily adopting additional process privileges to read a directory.

Definition at line 145 of file gdirectory.h.

Constructor & Destructor Documentation

G::DirectoryList::DirectoryList ( )

Default constructor for an empty list.

Initialise with one of the two read methods to do all the file i/o in one go.

Definition at line 74 of file gdirectory.cpp.

Member Function Documentation

void G::DirectoryList::readAll ( const Path dir)

An initialiser that is to be used after default construction.

Reads all files in the directory.

Definition at line 88 of file gdirectory.cpp.

void G::DirectoryList::readAll ( const Path dir,
std::vector< Item > &  out,
bool  sorted 
)
static

A static overload returning by reference a collection of Items.

Definition at line 80 of file gdirectory.cpp.

void G::DirectoryList::readType ( const Path dir,
const std::string &  suffix,
unsigned int  limit = 0U 
)

An initialiser that is to be used after default construction.

Reads all files that have the given suffix.

Definition at line 93 of file gdirectory.cpp.


The documentation for this class was generated from the following files: