StFile Class Reference

This class allows for basic file operations. More...

#include <stfile.h>

List of all members.

Public Member Functions

 StFile ()
 StFile (const StString &path, bool followSymLinks=false)
 StFile (const char *path, bool followSymLinks=false)
 StFile (const StFile &copy)
 ~StFile ()
void setPath (const StString &path, bool followSymLinks=false)
StString getPath () const
StString getBaseName ()
bool exists () const
void readStat (bool followSymLinks=true)
bool isDirectory () const
bool isSymLink () const
bool isRegular () const
bool isCharacterDevice () const
bool isBlockDevice () const
bool isFifo () const
bool isSocket () const
long size () const
bool remove ()
bool move (StString dest, bool overwrite=false)
bool copy (StString dest, bool overwrite=false)
StPermission getPermissions () const
bool changePermissions (const StPermission &perm)
bool changeOwner (const StPermission &perm)
bool open (SmartTools::OpenFileMode mode)
bool open (const StString &mode)
void close ()
unsigned read (void *buffer, unsigned size, unsigned count=1)
unsigned write (const void *buffer, unsigned size, unsigned count=1)
StString getLine ()
bool isEndOfFile ()
void operator= (const StString &path)
 operator StString () const
StFileoperator<< (const StString &string)
void clear ()

Private Member Functions

void init ()

Private Attributes

StString path
bool _exists
stat st
FILE * fPointer


Detailed Description

This class allows for basic file operations.

With StFile you can open, close, read, write, move, copy, and remove a file. It also allows operation on a file's permissions.


Constructor & Destructor Documentation

StFile::StFile (  )  [inline]

StFile::StFile ( const StString path,
bool  followSymLinks = false 
)

StFile::StFile ( const char *  path,
bool  followSymLinks = false 
) [inline]

StFile::StFile ( const StFile copy  )  [inline]

StFile::~StFile (  )  [inline]


Member Function Documentation

bool StFile::changeOwner ( const StPermission perm  ) 

Change owner and/or group if given.

bool StFile::changePermissions ( const StPermission perm  ) 

Change file's permissions

void StFile::clear (  ) 

Clear path and file's pointer.

void StFile::close (  )  [inline]

Close file.

bool StFile::copy ( StString  dest,
bool  overwrite = false 
)

Copy file to the dest.

bool StFile::exists (  )  const [inline]

Returns:
true or false depeding on if the file exists or not.

StString StFile::getBaseName (  ) 

Returns:
base name of file.

StString StFile::getLine (  ) 

Returns:
line from file.
Warning:
File must be opened first by open().

StString StFile::getPath (  )  const [inline]

Returns:
path to the file.

StPermission StFile::getPermissions (  )  const

Returns:
all permisions for this file.

void StFile::init (  )  [private]

bool StFile::isBlockDevice (  )  const [inline]

bool StFile::isCharacterDevice (  )  const [inline]

bool StFile::isDirectory (  )  const [inline]

bool StFile::isEndOfFile (  )  [inline]

bool StFile::isFifo (  )  const [inline]

bool StFile::isRegular (  )  const [inline]

bool StFile::isSocket (  )  const [inline]

bool StFile::isSymLink (  )  const [inline]

bool StFile::move ( StString  dest,
bool  overwrite = false 
)

Move file to the dest and change current path if succeed.

bool StFile::open ( const StString mode  ) 

Open file.

bool StFile::open ( SmartTools::OpenFileMode  mode  ) 

Open file.

StFile::operator StString (  )  const [inline]

Return path of file.

StFile& StFile::operator<< ( const StString string  )  [inline]

Write string to file.

Warning:
File must be opened first by open().

void StFile::operator= ( const StString path  )  [inline]

Set the path to the file.

unsigned StFile::read ( void *  buffer,
unsigned  size,
unsigned  count = 1 
) [inline]

Read from file to the buffer.

Parameters:
*buffer Pointer to the destination structure with a minimum size of (size*count) bytes.
size Size in bytes for each item to be read.
count Number of items, each one with a size in bytes.
Warning:
File must be open before this.
Returns:
The total number of items read is returned.

void StFile::readStat ( bool  followSymLinks = true  ) 

Read current file state

bool StFile::remove (  ) 

Remove a file.

void StFile::setPath ( const StString path,
bool  followSymLinks = false 
) [inline]

Set path to the file. It can follow symlinks.

long StFile::size (  )  const [inline]

Returns:
file's size.

unsigned StFile::write ( const void *  buffer,
unsigned  size,
unsigned  count = 1 
) [inline]

Write from buffer to the file.

Parameters:
*buffer Pointer to data to be written.
size Size in bytes of each item that has to be written.
count Number of items, each one with a size in bytes.
Warning:
File must be open before this.
Returns:
Number of full items (not bytes) successfully written.


Member Data Documentation

bool StFile::_exists [private]

FILE* StFile::fPointer [private]

StString StFile::path [private]

struct stat StFile::st [private]


The documentation for this class was generated from the following files:
Generated on Tue Nov 14 21:15:09 2006 for Smart Tools Library by  doxygen 1.4.7