Inherits YGP::IDirectorySearch.
Inherited by YGP::PathDirectorySearch.
Public Member Functions | |
DirectorySearch () | |
DirectorySearch (const std::string &search) | |
virtual | ~DirectorySearch () |
virtual void | setSearchValue (const std::string &search) |
virtual std::string | getDirectory () const |
virtual std::string | getFileSpec () const |
virtual bool | isValid () const |
Searching | |
const File * | find (const std::string &search, unsigned long attribs=IDirectorySearch::FILE_NORMAL) |
virtual const File * | find (unsigned long attribs=IDirectorySearch::FILE_NORMAL) |
virtual const File * | next () |
Static Public Member Functions | |
static bool | isValid (const std::string &dir) |
Protected Types | |
enum | { DIRSRCH_OK = 0, NO_ENTRY, NO_DIR, NO_FILE, LAST } |
Protected Member Functions | |
virtual int | checkIntegrity () const |
void | cleanup () |
Protected Attributes | |
std::string | searchDir |
std::string | searchFile |
unsigned long | attr |
This search can be restricted to files matching certain name-criterias or by attributes.
The name-part of the files to search supports UNIX-like wildcards; that are the asterisk (*) for any number of any characters, the question-mark for any single character and a set of characters in brackets (([) and (])). This set can contain a list of characters (like [abcde]) or a region (like [a-e]). To invert this set use a leading caret (^) or a leading exclamation mark (!), like ([^a-e]).
The found (and matching) files are retrieved by objects of type File.
anonymous enum [protected] |
YGP::DirectorySearch::DirectorySearch | ( | ) |
Defaultconstructor.
YGP::DirectorySearch::DirectorySearch | ( | const std::string & | search | ) |
Constructor; creates an object with the files to search.
The parameter may include path-information.
search | Files (including the path) to search for. |
YGP::DirectorySearch::~DirectorySearch | ( | ) | [virtual] |
Destructor.
int YGP::DirectorySearch::checkIntegrity | ( | ) | const [protected, virtual] |
Checks if this object is integer.
If yes 0 is returned, else a number describing the error.
void YGP::DirectorySearch::cleanup | ( | ) | [protected] |
Releases all internally used resources.
const File * YGP::DirectorySearch::find | ( | unsigned long | attribs = IDirectorySearch::FILE_NORMAL |
) | [virtual] |
Searches for previously specified files with the passed attributes.
Retrieves the first file matching the previously specified search-criteria.
attribs | Attributes the searched files must have |
attribs | Attributes the file must contain |
Implements YGP::IDirectorySearch.
Reimplemented in YGP::PathDirectorySearch.
const File* YGP::DirectorySearch::find | ( | const std::string & | search, | |
unsigned long | attribs = IDirectorySearch::FILE_NORMAL | |||
) | [inline] |
Searches for the specified files with the passed attributes.
search | Files to search for | |
attribs | Attributes the searched files must have |
Reimplemented in YGP::PathDirectorySearch.
virtual std::string YGP::DirectorySearch::getDirectory | ( | ) | const [inline, virtual] |
virtual std::string YGP::DirectorySearch::getFileSpec | ( | ) | const [inline, virtual] |
bool YGP::DirectorySearch::isValid | ( | const std::string & | dir | ) | [static] |
Checks if the passed string specifies an existing directory.
dir | Directory whose validity should be checked |
bool YGP::DirectorySearch::isValid | ( | ) | const [virtual] |
Checks if the directory-part of this object specifies an existing directory.
Implements YGP::IDirectorySearch.
const File * YGP::DirectorySearch::next | ( | ) | [virtual] |
Method to find the next file matching the previously specified values.
Returns the next matching file according to parameters specified in earlier find-calls.
Implements YGP::IDirectorySearch.
Reimplemented in YGP::PathDirectorySearch.
void YGP::DirectorySearch::setSearchValue | ( | const std::string & | search | ) | [virtual] |
Sets the value for the next search.
Internally it splits the search-string in its directory- and filepart; it prepares the internal data also for a new search.
search | Files to find |
Implements YGP::IDirectorySearch.
unsigned long YGP::DirectorySearch::attr [protected] |
Attributes the found file must have set.
std::string YGP::DirectorySearch::searchDir [protected] |
Holding the directory part of the search value.
std::string YGP::DirectorySearch::searchFile [protected] |
Holding the file part of the search value.