Inherited by YGP::RemoteFile.
Public Member Functions | |
File () | |
File (const char *name) throw (YGP::FileError) | |
File (const File &other) | |
virtual | ~File () |
File & | operator= (const File &other) |
File & | operator= (const char *name) throw (YGP::FileError) |
virtual File * | clone () const |
Query of data | |
const char * | path () const |
const char * | name () const |
unsigned long | size () const |
time_t | time () const |
void | time (struct tm &time) const |
void | localtime (struct tm &time) const |
unsigned long | attributes () const |
Compare filename | |
int | compare (const char *pszName) const |
int | compare (const std::string &Name) const |
int | compare (const File &other) const |
int | compare (const File *other) const |
File type | |
bool | isHidden () const |
bool | isDirectory () const |
bool | isExecuteable () const |
bool | isUserExec () const |
File access | |
virtual bool | isEOF (void *file) const throw (YGP::FileError) |
virtual void * | open (const char *mode) const throw (YGP::FileError) |
virtual void | close (void *file) const throw (YGP::FileError) |
virtual int | read (void *file, char *buffer, unsigned int length) const throw (YGP::FileError) |
virtual int | write (void *file, const char *buffer, unsigned int length) const throw (YGP::FileError) |
Static Public Attributes | |
static const char | DIRSEPARATOR = '/' |
Protected Member Functions | |
void | throwErrorText (const char *error) const throw (YGP::FileError) |
void | path (const char *path) |
void | path (const std::string &path) |
void | name (const char *name) |
void | name (const std::string &name) |
void | size (unsigned long size) |
void | time (time_t time) |
void | attributes (unsigned long attr) |
Protected Attributes | |
std::string | path_ |
struct dirent | entry |
struct stat | status |
bool | userExec |
Friends | |
class | DirectorySearch |
class | RemoteDirSearch |
This class provides simple management functions.
Objects of this type are usually returned as result of a DirectorySearch, but can also be used by themself.
YGP::File::File | ( | ) | [inline] |
Default constructor; creates an empty file object (holding no file).
YGP::File::File | ( | const char * | name | ) | throw (YGP::FileError) |
Constructor; create from a name.
name | Pointer to character-array holding name of file to create |
YGP::FileError | with a string describing the error |
YGP::File::File | ( | const File & | other | ) |
Copyconstructor.
other | Object to copy |
YGP::File::~File | ( | ) | [virtual] |
Destructor.
void YGP::File::attributes | ( | unsigned long | attr | ) | [inline, protected] |
Sets the attributes the file (only internally).
unsigned long YGP::File::attributes | ( | ) | const [inline] |
Returning the system attributes of the time.
File * YGP::File::clone | ( | ) | const [virtual] |
Duplicates (clones) the object and returns a pointer to the newly created object.
Reimplemented in YGP::RemoteFile.
void YGP::File::close | ( | void * | file | ) | const throw (YGP::FileError) [virtual] |
Closes a (previously opened) file.
file | Handle of opened file |
YGP::FileError | In case of an error with a textual description |
Reimplemented in YGP::RemoteFile.
int YGP::File::compare | ( | const File * | other | ) | const [inline] |
Checks if the file name matches those of the other object.
int YGP::File::compare | ( | const File & | other | ) | const [inline] |
Checks if the file name matches those of the other object.
int YGP::File::compare | ( | const std::string & | Name | ) | const [inline] |
Checks if the file name matches the passed text.
int YGP::File::compare | ( | const char * | pszName | ) | const [inline] |
Checks if the file name matches the passed text.
bool YGP::File::isDirectory | ( | ) | const [inline] |
Checks if file is actually a directory (a file (potentially) holding more files).
bool YGP::File::isEOF | ( | void * | file | ) | const throw (YGP::FileError) [virtual] |
Checks if further data is available for reading.
file | Handle of openeded file |
Reimplemented in YGP::RemoteFile.
bool YGP::File::isExecuteable | ( | ) | const [inline] |
Checks if file can be executed.
Returns true, if the file is executeable.
Under UNIX it checks the file-permissions (any execute-right is sufficient), under DOS/WINDOZE the extension of the file (EXE/COM/BAT).
bool YGP::File::isHidden | ( | ) | const [inline] |
Checks if the operating system "hides" this file during "normal" operation.
bool YGP::File::isUserExec | ( | ) | const [inline] |
Checks if file can be executed by the current user.
void YGP::File::localtime | ( | struct tm & | time | ) | const [inline] |
Retrieving the time the file was modified the last time (local time).
Returns the (local) time of the file in a (C-)struct tm.
time | Broken down time structure to set |
void YGP::File::name | ( | const std::string & | name | ) | [inline, protected] |
Sets the name of the file to the passed value (only internally).
void YGP::File::name | ( | const char * | name | ) | [inline, protected] |
Sets the name of the file to the passed value.
const char* YGP::File::name | ( | ) | const [inline] |
Returning the path to the file.
void * YGP::File::open | ( | const char * | mode | ) | const throw (YGP::FileError) [virtual] |
Opends the file in the specified mode.
The mode parameter can have the same values than the ANSI-C fopen-function.
mode | Mode for open the file (analogue to libc's fopen) |
YGP::FileError | In case of an error with a textual description |
Reimplemented in YGP::RemoteFile.
File & YGP::File::operator= | ( | const char * | name | ) | throw (YGP::FileError) |
Assignment operator; create from a name.
name,: | Name of file |
YGP::FileError | with a string describing the error |
void YGP::File::path | ( | const std::string & | path | ) | [inline, protected] |
Sets the path of the file (only internally).
void YGP::File::path | ( | const char * | path | ) | [inline, protected] |
Sets the path of the file (only internally).
const char* YGP::File::path | ( | ) | const [inline] |
Returning the file name.
int YGP::File::read | ( | void * | file, | |
char * | buffer, | |||
unsigned int | length | |||
) | const throw (YGP::FileError) [virtual] |
Reads the (next) specified number of characters from the (previously opened) file (or less, if the end of the file has been reached) into buffer.
and returns the number of actually read bytes. If an error occurres, an exception is thrown
file | Handle of openeded file | |
buffer | Buffer for data | |
length | Maximal length of buffer |
YGP::FileError | In case of an error a textual description |
Reimplemented in YGP::RemoteFile.
void YGP::File::size | ( | unsigned long | size | ) | [inline, protected] |
Sets the size of the file (only internally).
unsigned long YGP::File::size | ( | ) | const [inline] |
Returning the size of the file.
void YGP::File::throwErrorText | ( | const char * | error | ) | const throw (YGP::FileError) [protected] |
Throws an error consisting of the passed string, where the characters '1' are subsituted with the name of the file and '2' with an error message (according to strerror).
error | ASCIIZ-String describing error-message |
YGP::FileError | In case of an error |
void YGP::File::time | ( | time_t | time | ) | [inline, protected] |
Sets the last modification time of the file (only internally).
void YGP::File::time | ( | struct tm & | time | ) | const [inline] |
Retrieving the time the file was modified the last time (GMT).
time_t YGP::File::time | ( | ) | const [inline] |
Returning the time the file was modified the last time.
Retrieves the modification time of the file in the format of the system-time.
int YGP::File::write | ( | void * | file, | |
const char * | buffer, | |||
unsigned int | length | |||
) | const throw (YGP::FileError) [virtual] |
Writes the specified number of characters to the (previously opened) file and returns the number of actually written bytes.
If an error occurres, an exception is thrown.
file | Handle of openeded file | |
buffer | Buffer of data | |
length | Length of buffer (= bytes to write) |
YGP::FileError | In case of an error a textual description |
Reimplemented in YGP::RemoteFile.
friend class DirectorySearch [friend] |
Class mainly using File.
friend class RemoteDirSearch [friend] |
Class mainly using File.
const char YGP::File::DIRSEPARATOR = '/' [static] |
< Character to separte directories of the operating system
struct dirent YGP::File::entry [read, protected] |
File entry (as seen by the OS - don't access directly).
std::string YGP::File::path_ [protected] |
Path of the file (don't access directly).
struct stat YGP::File::status [read, protected] |
Attributes of the file (don't access directly).
bool YGP::File::userExec [protected] |
Flag, if the file can be executed by the current user (don't access directly).