YGP::RemoteDirSearch Class Reference

Class to search for files in a directory over a network-connection. More...

Inherits YGP::IDirectorySearch.

List of all members.

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 Filefind (unsigned long attribs=FILE_NORMAL) throw (YGP::CommError, YGP::FileError)
virtual const Filenext () throw (YGP::CommError, YGP::FileError)

Static Public Attributes

static const char SEPARATOR = ':'

Protected Attributes

Socket sock


Detailed Description

Class to search for files in a directory over a network-connection.

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)!


Member Enumeration Documentation

Enumerator:
FILE_NORMAL  Ordinary file.
FILE_READONLY  File is readonly
FILE_DIRECTORY  File is actually a directory
FILE_HIDDEN  File is "hidden"


Constructor & Destructor Documentation

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).

Parameters:
srch String identifying server/port and path to search; in a format <server>:<path>:<port>
Exceptions:
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.

Parameters:
srch String identifying server and path to search; <server>:<path>
port Port number the server is listening at
Exceptions:
YGP::CommError Containing error message in case of an error

YGP::RemoteDirSearch::~RemoteDirSearch (  )  [virtual]

Destructor.


Member Function Documentation

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!

Parameters:
attribs Attributes of files to find
Returns:
const File* Pointer to found file-object or NULL
Exceptions:
YGP::FileError,YGP::CommError Containing error message in case of an error
Precondition:
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).

Returns:
std::string Directory to search for

Implements YGP::IDirectorySearch.

std::string YGP::RemoteDirSearch::getFileSpec (  )  const [virtual]

Retrieves the name of the files to search.

Returns:
std::string Files to find

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).

Parameters:
dir Directory (without server-part) whose validity should be checked.
Returns:
bool True if the directory exists.
Exceptions:
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.

Returns:
bool True if the directory exists
Exceptions:
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.

Returns:
const File* Pointer to found file-object or NULL
Precondition:
A find must have been (successfully) performed
Exceptions:
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.

Parameters:
search String identifying server to connect to.
port Port number the server is listening at.
Exceptions:
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.

Parameters:
search Files to search for

Implements YGP::IDirectorySearch.


Member Data Documentation

const char YGP::RemoteDirSearch::SEPARATOR = ':' [static]

Separator between host and port.

Socket for the communication.


The documentation for this class was generated from the following files:

YGP Version 0.9.31 - Generated on Wed Nov 18 11:25:28 2009 by doxygen 1.5.8