Main Page   Class Hierarchy   Alphabetical List   Data Structures   File List   Data Fields  

clawsoft::BaseFile Class Reference

#include <BaseFile.h>

Inheritance diagram for clawsoft::BaseFile:

Inheritance graph
[legend]
Collaboration diagram for clawsoft::BaseFile:

Collaboration graph
[legend]

Detailed Description

This class implements the basic File I/O handling stuff, it is the base of every file-based UNIX subsystem.

This class does not implement buffering


Public Types

enum  chmodBits {
  SET_UID = 04000, SET_GID = 02000, STICKY = 01000, OWNER_READ = 00400,
  OWNER_WRITE = 00200, OWNER_EXEC = 00100, GROUP_READ = 00040, GROUP_WRITE = 00020,
  GROUP_EXEC = 00010, OTHER_READ = 00004, OTHER_WRITE = 00002, OTHER_EXEC = 00001
}
 To set permissions on a file please use an ORed combination of the following data. More...

enum  OffsetStartingPoint { FROM_THE_BEGINING, FROM_CURRENT_POSITION, FROM_THE_END }
 Use this enum when u want to call the setOffset method. More...

enum  FileOpenMode { READ_ONLY, WRITE_ONLY, READ_WRITE, APPEND }
 Use this enum to identify the type of the file to be open. More...


Public Methods

 BaseFile ()
 Default constructor initializes the filename to /dev/null.

 BaseFile (const char *fname)
 This will initialize the filename to the specified by fname.

virtual void open (FileOpenMode mode)
 This method will open a file with the given openmode.

virtual void open (const char *fname, FileOpenMode mode)
 This method will open a file with the given openmode and will set the filename to fname.

virtual void open (const String &fname, FileOpenMode mode)
 This method will open a file with the given openmode and will set the filename to fname.

virtual Uint32 getOffset ()
 This method will give you the offset for the file pointer, is very usefull when you are dealing with random files.

virtual Uint32 setOffset (Uint32 off, OffsetStartingPoint from=BaseFile::FROM_THE_BEGINING)
 This method will set the offset for the file pointer, is very usefull when you are dealing with random files.

virtual void close ()
 Calling this will close the currently opened file.

virtual void flush ()
 This will write all content in the file buffers to the destination file.

Uint32 getSize ()
 Obtain the size of the current file it doesn't matter if the file is already opened or not.

int chmod (int perms)
 Change the reading permission per file as in the chmod system call.

virtual Uint32 write (const void *buffer, Uint32 size)
 Sends the data buffer specified by buffer to the current file which has size bytes.

virtual Uint32 write (const char *buffer)
 Sends the data buffer specified by buffer to the current file.

virtual Uint32 read (void *buffer, Uint32 size)
 Retrieves size bytes from the data buffer specified by buffer from the current file.

bool isOpen ()
 Will tell you if the file is currently open.

const char * getClassName ()
 Returns the name of the current class.


Static Public Methods

int installedCPUs ()
 This will return how many CPUs are installed in the system.

double cpuSpeed ()
 This will return the CPU speed in megahertz.

int totalMemory ()
 Will return the total amount of system memory.

int freeMemory ()
 Will return the total amount of free system memory.

void usleep (Uint32 usec)
 Will freeze the software for usec microseconds.


Protected Methods

void setClassName (const char *n)
 Call this method when you need to set the name of the class you're creating, typically in it's constructor, remember that you must set the classname for every class you create, that way you can have more information while debugging.


Protected Attributes

int handler
 Base file handler, this is just a reference pointer to the opened file in the OS.

String filename
 This will store the associated filename.

int filemode
 This variable stores the current file opening mode.

bool _opened
 This flag will say if the file is currently opened or not.


Member Enumeration Documentation

enum clawsoft::BaseFile::chmodBits
 

To set permissions on a file please use an ORed combination of the following data.

Enumeration values:
SET_UID  Set user id on execution.
SET_GID  Set group id on execution.
STICKY  Set the sticky bit.
OWNER_READ  Owner can read.
OWNER_WRITE  Owner can write.
OWNER_EXEC  Owner can execute, search.
GROUP_READ  Group can read.
GROUP_WRITE  Group can write.
GROUP_EXEC  Group can execute, search.
OTHER_READ  Others can read.
OTHER_WRITE  Others can write.
OTHER_EXEC  Others can execute, search.

enum clawsoft::BaseFile::FileOpenMode
 

Use this enum to identify the type of the file to be open.

Enumeration values:
READ_ONLY  The file can only be read, secuentially.
WRITE_ONLY  The file can only be write, secuentially.
READ_WRITE  The file can be read-written, be carefull if your writing data to an already existing file.
APPEND  The file is open for writing at the end.

enum clawsoft::BaseFile::OffsetStartingPoint
 

Use this enum when u want to call the setOffset method.

Enumeration values:
FROM_THE_BEGINING  Move the offset from the begining of the file.
FROM_CURRENT_POSITION  Move the offset from the file pointer's current position.
FROM_THE_END  Move the offset backwards from the end of the file.


Constructor & Destructor Documentation

clawsoft::BaseFile::BaseFile  
 

Default constructor initializes the filename to /dev/null.

clawsoft::BaseFile::BaseFile const char *    fname
 

This will initialize the filename to the specified by fname.


Member Function Documentation

int clawsoft::BaseFile::chmod int    perms
 

Change the reading permission per file as in the chmod system call.

void clawsoft::BaseFile::close   [virtual]
 

Calling this will close the currently opened file.

double clawsoft::System::cpuSpeed   [static, inherited]
 

This will return the CPU speed in megahertz.

void clawsoft::BaseFile::flush   [virtual]
 

This will write all content in the file buffers to the destination file.

int clawsoft::System::freeMemory   [static, inherited]
 

Will return the total amount of free system memory.

const char * clawsoft::Object::getClassName   [inherited]
 

Returns the name of the current class.

Uint32 clawsoft::BaseFile::getOffset   [virtual]
 

This method will give you the offset for the file pointer, is very usefull when you are dealing with random files.

Uint32 clawsoft::BaseFile::getSize  
 

Obtain the size of the current file it doesn't matter if the file is already opened or not.

int clawsoft::System::installedCPUs   [static, inherited]
 

This will return how many CPUs are installed in the system.

bool clawsoft::BaseFile::isOpen   [inline]
 

Will tell you if the file is currently open.

void clawsoft::BaseFile::open const String   fname,
FileOpenMode    mode
[virtual]
 

This method will open a file with the given openmode and will set the filename to fname.

void clawsoft::BaseFile::open const char *    fname,
FileOpenMode    mode
[virtual]
 

This method will open a file with the given openmode and will set the filename to fname.

void clawsoft::BaseFile::open FileOpenMode    mode [virtual]
 

This method will open a file with the given openmode.

Uint32 clawsoft::BaseFile::read void *    buffer,
Uint32    size
[virtual]
 

Retrieves size bytes from the data buffer specified by buffer from the current file.

void clawsoft::Object::setClassName const char *    n [protected, inherited]
 

Call this method when you need to set the name of the class you're creating, typically in it's constructor, remember that you must set the classname for every class you create, that way you can have more information while debugging.

Uint32 clawsoft::BaseFile::setOffset Uint32    off,
OffsetStartingPoint    from = BaseFile::FROM_THE_BEGINING
[virtual]
 

This method will set the offset for the file pointer, is very usefull when you are dealing with random files.

int clawsoft::System::totalMemory   [static, inherited]
 

Will return the total amount of system memory.

void clawsoft::System::usleep Uint32    usec [static, inherited]
 

Will freeze the software for usec microseconds.

Uint32 clawsoft::BaseFile::write const char *    buffer [virtual]
 

Sends the data buffer specified by buffer to the current file.

Uint32 clawsoft::BaseFile::write const void *    buffer,
Uint32    size
[virtual]
 

Sends the data buffer specified by buffer to the current file which has size bytes.


Field Documentation

bool clawsoft::BaseFile::_opened [protected]
 

This flag will say if the file is currently opened or not.

int clawsoft::BaseFile::filemode [protected]
 

This variable stores the current file opening mode.

String clawsoft::BaseFile::filename [protected]
 

This will store the associated filename.

int clawsoft::BaseFile::handler [protected]
 

Base file handler, this is just a reference pointer to the opened file in the OS.


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

Authors:

Juan V. Guerrero
Jannette C. Mejia
Juan C. Guevara

Powered by:

SourceForgeLogo