#include <UDirectory.h>
Public Member Functions | |
const std::list< std::string > & | getFileNames () const |
std::string | getNextFileName () |
std::string | getNextFilePath () |
bool | isValid () |
UDirectory & | operator= (const UDirectory &dir) |
void | rewind () |
void | setPath (const std::string &path, const std::string &extensions="") |
UDirectory (const std::string &path="", const std::string &extensions="") | |
UDirectory (const UDirectory &dir) | |
void | update () |
~UDirectory () | |
Static Public Member Functions | |
static std::string | currentDir (bool trailingSeparator=false) |
static bool | exists (const std::string &dirPath) |
static std::string | getDir (const std::string &filePath) |
static std::string | homeDir () |
static bool | makeDir (const std::string &dirPath) |
static bool | removeDir (const std::string &dirPath) |
static std::string | separator () |
Private Attributes | |
std::vector< std::string > | extensions_ |
std::list< std::string > | fileNames_ |
std::list< std::string >::iterator | iFileName_ |
std::string | path_ |
Class UDirectory.
This class can be used to get file names in a directory.
Definition at line 34 of file UDirectory.h.
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".
path | the path to an existing directory |
extensions | filter 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. |
Definition at line 62 of file UDirectory.cpp.
UDirectory::UDirectory | ( | const UDirectory & | dir | ) |
Definition at line 70 of file UDirectory.cpp.
Definition at line 90 of file UDirectory.cpp.
std::string UDirectory::currentDir | ( | bool | trailingSeparator = false | ) | [static] |
Get the current directory.
trailingSeparator | If true, a '/' is added to the path. |
Definition at line 308 of file UDirectory.cpp.
bool UDirectory::exists | ( | const std::string & | dirPath | ) | [static] |
Check if a directory exists.
dirPath | the directory path |
Definition at line 248 of file UDirectory.cpp.
std::string UDirectory::getDir | ( | const std::string & | filePath | ) | [static] |
Get the directory path of a file path.
filePath | the file path |
Definition at line 272 of file UDirectory.cpp.
const std::list<std::string>& UDirectory::getFileNames | ( | ) | const [inline] |
Get all file names.
Definition at line 129 of file UDirectory.h.
std::string UDirectory::getNextFileName | ( | ) |
std::string UDirectory::getNextFilePath | ( | ) |
std::string UDirectory::homeDir | ( | ) | [static] |
Return the "home" directory.
Definition at line 354 of file UDirectory.cpp.
bool UDirectory::isValid | ( | ) |
Check is the directory exists.
Definition at line 215 of file UDirectory.cpp.
bool UDirectory::makeDir | ( | const std::string & | dirPath | ) | [static] |
Make a directory.
dirPath | the directory path |
Definition at line 332 of file UDirectory.cpp.
UDirectory & UDirectory::operator= | ( | const UDirectory & | dir | ) |
Definition at line 75 of file UDirectory.cpp.
bool UDirectory::removeDir | ( | const std::string & | dirPath | ) | [static] |
Remove a directory.
dirPath | the directory path |
Definition at line 343 of file UDirectory.cpp.
void UDirectory::rewind | ( | ) |
Return the pointer of file names to beginning.
Definition at line 242 of file UDirectory.cpp.
std::string UDirectory::separator | ( | ) | [static] |
Return \ (Win32) or / (Unix) depending of the platform.
Definition at line 375 of file UDirectory.cpp.
void UDirectory::setPath | ( | const std::string & | path, |
const std::string & | extensions = "" |
||
) |
Set path of the directory.
path | the new directory path. |
Definition at line 94 of file UDirectory.cpp.
void UDirectory::update | ( | ) |
Update indexed file names (if the directory changed).
Definition at line 103 of file UDirectory.cpp.
std::vector<std::string> UDirectory::extensions_ [private] |
Definition at line 138 of file UDirectory.h.
std::list<std::string> UDirectory::fileNames_ [private] |
Definition at line 139 of file UDirectory.h.
std::list<std::string>::iterator UDirectory::iFileName_ [private] |
Definition at line 140 of file UDirectory.h.
std::string UDirectory::path_ [private] |
Definition at line 137 of file UDirectory.h.