Inherits YGP::IDirectorySearch.
Public Types | |
enum | FileType { FILE_NORMAL = 0, FILE_READONLY = 1, FILE_DIRECTORY = 2, FILE_HIDDEN = 4 } |
Public Member Functions | |
RemoteDirSearch (const std::string &search) throw (YGP::CommError) | |
RemoteDirSearch (const std::string &search, unsigned int port) throw (YGP::CommError) | |
virtual | ~RemoteDirSearch () |
void | sendTo (const std::string &server, unsigned int port) throw (YGP::CommError) |
virtual void | setSearchValue (const std::string &search) |
virtual std::string | getDirectory () const |
virtual std::string | getFileSpec () const |
virtual bool | isValid () const throw (YGP::CommError) |
bool | isValid (const std::string &dir) throw (YGP::CommError) |
Searching | |
virtual const File * | find (unsigned long attribs=FILE_NORMAL) throw (YGP::CommError, YGP::FileError) |
virtual const File * | next () throw (YGP::CommError, YGP::FileError) |
Static Public Attributes | |
static const char | SEPARATOR = ':' |
Protected Attributes | |
Socket | sock |
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.
Note: The class does not do any word expansion for the search-path (like expanding the tilde (~) to the home-directory)!
YGP::RemoteDirSearch::RemoteDirSearch | ( | const std::string & | srch | ) | throw (YGP::CommError) |
Constructor; sets the information for which files to search.
The port-part of the srch-parameter can be both numeric or its equivalent textual representation (e.g.: 80
or http
).
srch | String identifying server/port and path to search; in a format <server>:<path>:<port> |
YGP::CommError | Containing error message in case of an error |
YGP::RemoteDirSearch::RemoteDirSearch | ( | const std::string & | srch, | |
unsigned int | port | |||
) | throw (YGP::CommError) |
Constructor; sets the information for which files to search.
srch | String identifying server and path to search; <server>:<path> | |
port | Port number the server is listening at |
YGP::CommError | Containing error message in case of an error |
YGP::RemoteDirSearch::~RemoteDirSearch | ( | ) | [virtual] |
Destructor.
const File * YGP::RemoteDirSearch::find | ( | unsigned long | attribs = FILE_NORMAL |
) | throw (YGP::CommError, YGP::FileError) [virtual] |
Searches for first file matching the input specified by the constructor(s) or the set-methods.
Only files matching also the attributes are returned!
attribs | Attributes of files to find |
NULL
YGP::FileError,YGP::CommError | Containing error message in case of an error |
searchDir
, pEntry
already set Implements YGP::IDirectorySearch.
std::string YGP::RemoteDirSearch::getDirectory | ( | ) | const [virtual] |
Retrieves the directory-part of the files to search for (including server).
Implements YGP::IDirectorySearch.
std::string YGP::RemoteDirSearch::getFileSpec | ( | ) | const [virtual] |
Retrieves the name of the files to search.
Implements YGP::IDirectorySearch.
bool YGP::RemoteDirSearch::isValid | ( | const std::string & | dir | ) | throw (YGP::CommError) |
Checks if the passed string specifies an existing directory (on the server).
dir | Directory (without server-part) whose validity should be checked. |
YGP::CommError | in case of an error during the communication. |
bool YGP::RemoteDirSearch::isValid | ( | ) | const throw (YGP::CommError) [virtual] |
Checks if the directory-part of the object specifies an existing directory.
YGP::CommError | in case of an error during the communication |
Implements YGP::IDirectorySearch.
const File * YGP::RemoteDirSearch::next | ( | ) | throw (YGP::CommError, YGP::FileError) [virtual] |
Returns the next matching file according to the parameters specified in earlier find-calls.
YGP::FileError,YGP::CommError | Containing error message in case of an error |
Implements YGP::IDirectorySearch.
void YGP::RemoteDirSearch::sendTo | ( | const std::string & | search, | |
unsigned int | port | |||
) | throw (YGP::CommError) |
Specifies the partner (name and port) for the communication.
search | String identifying server to connect to. | |
port | Port number the server is listening at. |
YGP::CommError | With an error message in case of an error |
void YGP::RemoteDirSearch::setSearchValue | ( | const std::string & | search | ) | [virtual] |
Sets the files to search for (including server and path where to search).
The search-string must be in the format server:[path]files
.
search | Files to search for |
Implements YGP::IDirectorySearch.
const char YGP::RemoteDirSearch::SEPARATOR = ':' [static] |
Separator between host and port.
Socket YGP::RemoteDirSearch::sock [protected] |
Socket for the communication.