YGP::File Struct Reference

Class representing a file in the file system of the operating system. More...

Inherited by YGP::RemoteFile.

List of all members.

Public Member Functions

 File ()
 File (const char *name) throw (YGP::FileError)
 File (const File &other)
virtual ~File ()
Fileoperator= (const File &other)
Fileoperator= (const char *name) throw (YGP::FileError)
virtual Fileclone () 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


Detailed Description

Class representing a file in the file system of the operating system.

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.


Constructor & Destructor Documentation

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.

Parameters:
name Pointer to character-array holding name of file to create
Exceptions:
YGP::FileError with a string describing the error

YGP::File::File ( const File other  ) 

Copyconstructor.

Parameters:
other Object to copy

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

Destructor.


Member Function Documentation

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.

Returns:
File* Pointer to newly created clone

Reimplemented in YGP::RemoteFile.

void YGP::File::close ( void *  file  )  const throw (YGP::FileError) [virtual]

Closes a (previously opened) file.

Parameters:
file Handle of opened file
Exceptions:
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.

Parameters:
file Handle of openeded file
Returns:
bool True, if further data is available

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

Returns:
bool Flag, if file is executeable
Remarks:
  • VBS, WSH, and whatever Windows executes directly are not considered as executable.
  • The call is only valid with a defined object

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.

Parameters:
time Broken down time structure to set
Remarks:
The call is only valid with a valid object

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.

Parameters:
mode Mode for open the file (analogue to libc's fopen)
Returns:
void* Pointer to a handle for the opened file.
Exceptions:
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.

Parameters:
name,: Name of file
Returns:
Reference to self
Exceptions:
YGP::FileError with a string describing the error

File & YGP::File::operator= ( const File other  ) 

Assignment operator.

Parameters:
other Object to copy
Returns:
File& Reference to this

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

Parameters:
file Handle of openeded file
buffer Buffer for data
length Maximal length of buffer
Returns:
int Number of read bytes
Exceptions:
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).

Parameters:
error ASCIIZ-String describing error-message
Precondition:
error != NULL, an ASCIIZ-string with the placeholders 1, 2
Exceptions:
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.

Returns:
time_t Filetime in system format
Remarks:
The call is only valid after a successfull find.

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.

Parameters:
file Handle of openeded file
buffer Buffer of data
length Length of buffer (= bytes to write)
Returns:
int Number of written bytes
Exceptions:
YGP::FileError In case of an error a textual description

Reimplemented in YGP::RemoteFile.


Friends And Related Function Documentation

friend class DirectorySearch [friend]

Class mainly using File.

friend class RemoteDirSearch [friend]

Class mainly using File.


Member Data Documentation

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


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

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