All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
Radiant::Directory Class Reference

Class for reading filenames in a directory. More...

#include <Radiant/Directory.hpp>

Public Types

enum  FilterFlags {
  DIRS = 0x001, FILES = 0x002, NO_DOT_AND_DOTDOT = 0x1000, HIDDEN = 0x100,
  SYSTEM = 0x004, ALL_ENTRIES = DIRS | FILES | SYSTEM
}
 Flags to filter directory contents. More...
 
enum  SortFlag { NAME = 0x00, NOT_SORTED = 0x03 }
 Flags to sort files. More...
 

Public Member Functions

int count () const
 Returns the number of entries in the directory. More...
 
 Directory (const QString &pathname, int filters=ALL_ENTRIES|NO_DOT_AND_DOTDOT, SortFlag sortFlag=NAME)
 Construct a directory listing Creating a Directory object immediately scans the contents of the directory. More...
 
 Directory (const QString &pathname, const QString &suffixlist, int filters=ALL_ENTRIES|NO_DOT_AND_DOTDOT, SortFlag sortFlag=NAME)
 Construct a directory listing Creating a Directory object immediately scans the contents of the directory. More...
 
QString fileName (int n) const
 Return given entry name in the directory. More...
 
QString fileNameWithPath (int n) const
 Get the full path name of the nth file. More...
 
const QString & path () const
 Returns the directory path. More...
 
virtual ~Directory ()
 Destructor.
 

Static Public Member Functions

static bool exists (const QString &dir)
 Checks if the given directory exists. More...
 
static Directory findByMimePattern (const QString &pathname, const QString &mimePattern, int filters=ALL_ENTRIES|NO_DOT_AND_DOTDOT, SortFlag sortFlag=NAME)
 Create a directory listing with MIME pattern filtering. More...
 
static bool mkdir (const QString &dirname)
 Creates a new directory. More...
 
static bool mkdirRecursive (const QString &path)
 Creates a new directory recursively. More...
 

Detailed Description

Class for reading filenames in a directory.

This class exists because there exists no portable way to read directories (which is sad).

Author
Esa Nuuros
Examples:
PostProcessingExample.cpp.

Member Enumeration Documentation

Flags to filter directory contents.

Enumerator
DIRS 

Accept directories.

FILES 

Accept Files.

NO_DOT_AND_DOTDOT 

Do not accept "." or "..".

HIDDEN 

Accept hidden files/directories.

SYSTEM 

Accept system system files.

ALL_ENTRIES 

Accept everything.

Flags to sort files.

Enumerator
NAME 

Sort by name.

NOT_SORTED 

Do not sort.

Constructor & Destructor Documentation

Radiant::Directory::Directory ( const QString &  pathname,
int  filters = ALL_ENTRIES|NO_DOT_AND_DOTDOT,
SortFlag  sortFlag = NAME 
)

Construct a directory listing Creating a Directory object immediately scans the contents of the directory.

Entries matching the given filters are included.

Parameters
pathnamedirectory path
filtersone or more filter flags OR'ed together
sortFlagflag indicating how the results should be sorted
Radiant::Directory::Directory ( const QString &  pathname,
const QString &  suffixlist,
int  filters = ALL_ENTRIES|NO_DOT_AND_DOTDOT,
SortFlag  sortFlag = NAME 
)

Construct a directory listing Creating a Directory object immediately scans the contents of the directory.

Entries matching the given filters are included.

Parameters
pathnamedirectory path
suffixlistlist of accpeted suffices, for example "jpg,png,tiff"
filtersone or more filter flags OR'ed together
sortFlagflag indicating how the results should be sorted

Member Function Documentation

int Radiant::Directory::count ( ) const

Returns the number of entries in the directory.

Returns
Number of filtered entries
Examples:
PostProcessingExample.cpp.
static bool Radiant::Directory::exists ( const QString &  dir)
static

Checks if the given directory exists.

Parameters
dirDirectory to search
Returns
True if exists, false otherwise
QString Radiant::Directory::fileName ( int  n) const

Return given entry name in the directory.

Parameters
nindex of item in selected sorting scheme
Returns
filename of selected item
QString Radiant::Directory::fileNameWithPath ( int  n) const

Get the full path name of the nth file.

This method is equal to concatenation of strings returned by path and fileName.

Parameters
nindex of the file
Returns
full path to the requested file
Examples:
PostProcessingExample.cpp.
static Directory Radiant::Directory::findByMimePattern ( const QString &  pathname,
const QString &  mimePattern,
int  filters = ALL_ENTRIES|NO_DOT_AND_DOTDOT,
SortFlag  sortFlag = NAME 
)
static

Create a directory listing with MIME pattern filtering.

Parameters
pathnamepath of the directory
mimePatternmime pattern for files to match
filtersone or more filters flags
sortFlagflag indicating how the results are sorted
Returns
directory object with the matching filters
Examples:
HelloImagesExample.cpp, PositionalSoundsExample.cpp, and SamplePlayerExample.cpp.
static bool Radiant::Directory::mkdir ( const QString &  dirname)
static

Creates a new directory.

Parameters
dirnameName of the directory to create
Returns
True if creation succeeded, false otherwise
static bool Radiant::Directory::mkdirRecursive ( const QString &  path)
static

Creates a new directory recursively.

Parameters
pathPath to new directory
Returns
True if succeeded, false otherwise
const QString& Radiant::Directory::path ( ) const
inline

Returns the directory path.

Returns
Path to the directory