UtiLite  0.3.1
A lite utilities library
Public Member Functions | Static Public Member Functions
UDirectory Class Reference

#include <UDirectory.h>

List of all members.

Public Member Functions

 UDirectory (const std::string &path="", const std::string &extensions="")
void setPath (const std::string &path, const std::string &extensions="")
void update ()
bool isValid ()
std::string getNextFileName ()
const std::list< std::string > & getFileNames () const
void rewind ()

Static Public Member Functions

static bool exists (const std::string &dirPath)
static std::string getDir (const std::string &filePath)
static std::string currentDir (bool trailingSeparator=false)
static bool makeDir (const std::string &dirPath)
static bool removeDir (const std::string &dirPath)
static std::string homeDir ()
static std::string separator ()

Detailed Description

Class UDirectory.

This class can be used to get file names in a directory.


Constructor & Destructor Documentation

UDirectory::UDirectory ( const std::string &  path = "",
const std::string &  extensions = "" 
)

Create a UDirectory object with path initialized to an existing "path" and with filter "extensions".

Parameters:
paththe path to an existing directory
extensionsfilter to get only file names with the extensions specified, format is a list of extensions separated by a space: "jpg bmp" get only file names finishing by jpg or bmp.

Member Function Documentation

std::string UDirectory::currentDir ( bool  trailingSeparator = false) [static]

Get the current directory.

Parameters:
trailingSeparatorIf true, a '/' is added to the path.
Returns:
the current directory
bool UDirectory::exists ( const std::string &  dirPath) [static]

Check if a directory exists.

Parameters:
dirPaththe directory path
Returns:
true if the directory exists
std::string UDirectory::getDir ( const std::string &  filePath) [static]

Get the directory path of a file path.

Parameters:
filePaththe file path
Returns:
the directory path of the file
const std::list<std::string>& UDirectory::getFileNames ( ) const [inline]

Get all file names.

See also:
UDirectory()
Returns:
all the file names in directory matching the set extensions.
std::string UDirectory::getNextFileName ( )

Get the next file name.

Returns:
the next file name
std::string UDirectory::homeDir ( ) [static]

Return the "home" directory.

Returns:
the directory path.

Check is the directory exists.

Returns:
if directory exists.
bool UDirectory::makeDir ( const std::string &  dirPath) [static]

Make a directory.

Parameters:
dirPaththe directory path
Returns:
true on success, false otherwise.
bool UDirectory::removeDir ( const std::string &  dirPath) [static]

Remove a directory.

Parameters:
dirPaththe directory path
Returns:
true on success, false otherwise.

Return the pointer of file names to beginning.

std::string UDirectory::separator ( ) [static]

Return \ (Win32) or / (Unix) depending of the platform.

void UDirectory::setPath ( const std::string &  path,
const std::string &  extensions = "" 
)

Set path of the directory.

Parameters:
paththe new directory path.

Update indexed file names (if the directory changed).


The documentation for this class was generated from the following files:
 All Classes Files Functions Variables Enumerations Friends Defines