StdioFile Class Reference

Standard I/O file class. More...

#include <StdioFile.h>

List of all members.

Public Types

enum  OpenMode {
  ModeRead, ModeWrite, ModeReadWrite, ModeAppend,
  ModeUpdate
}

Public Member Functions

 StdioFile ()
 Class constructor.
virtual ~StdioFile ()
 Class destructor.
bool open (const char *fileName, OpenMode mode)
 Open file.
bool close ()
 Close file.
bool isEOF ()
 Get End-of-File flag.
bool writeData (const void *pData, size_t dataLen)
 Write data to file.
size_t readData (void *pData, size_t maxLen)
 Read data from file.
long getSize ()
 Get file size.
bool writeString (const char *strData)
 Write string to file.
std::string readString ()
 Read string from file.

Protected Attributes

FILE * fileStream

Detailed Description

Standard I/O file class.

I/O file class is a wrapper for basic libC stream I/O calls. StdioFile class also calls Media class methods internally, to support for transparent media mounting.


Member Enumeration Documentation

File access modes

Enumerator:
ModeRead 

Read only access. Opening fails if the file does not exist.

ModeWrite 

Write only access. The file is truncated if it exists already, otherwise a new file is created.

ModeReadWrite 

Read and write access. The file is created if it does not exist, otherwise it is truncated.

ModeAppend 

Read and append access. The file is created if it does not exist.

ModeUpdate 

Open a file for update both reading and writing. The file must exist.


Constructor & Destructor Documentation

StdioFile::StdioFile (  ) 

Class constructor.

Initializes the I/O file object.

StdioFile::~StdioFile (  )  [virtual]

Class destructor.

Destroys the I/O file object.


Member Function Documentation

bool StdioFile::close (  ) 

Close file.

Closes the stream file. If the media was mounted associated with this file, it will be automatically unmounted, provided that no other files are open on that media.

Returns:
Returns true if the file was successfully closed.
long StdioFile::getSize (  ) 

Get file size.

Get the length of the file

Returns:
Returns the length of the file in bytes or -1 in case of error.
bool StdioFile::isEOF (  ) 

Get End-of-File flag.

Returns:
Returns true if end of file has been reached.
bool StdioFile::open ( const char *  fileName,
OpenMode  mode 
)

Open file.

Opens a stream file with the given file name. When required, the corresponding media will be also mounted.

Parameters:
fileName Contains the file name.
mode Specifies the file access mode.
Returns:
Returns true if the file was opened successfully.
size_t StdioFile::readData ( void *  pData,
size_t  maxLen 
)

Read data from file.

Reads the data from file to a specified buffer.

Parameters:
pData Pointer to the data buffer.
maxLen Specifies the length of the data to be read.
Returns:
Returns number of bytes actually read from the file.
std::string StdioFile::readString (  ) 

Read string from file.

Reads a string from the file.

Returns:
Returns the STL string object.
bool StdioFile::writeData ( const void *  pData,
size_t  dataLen 
)

Write data to file.

Writes the given data buffer to file at the current position.

Parameters:
pData Points to the data buffer.
dataLen Specifies the length of the data buffer.
Returns:
Returns true if the buffer has been written successfully.
bool StdioFile::writeString ( const char *  strData  ) 

Write string to file.

Writes the specified string to the file at the current position.

Parameters:
strData Pointer to a null terminated character string.
Returns:
Return true if the string has been written successfully.

Member Data Documentation

FILE* StdioFile::fileStream [protected]

File handle for currently opened file


The documentation for this class was generated from the following files:
Generated on Wed Oct 20 11:13:45 2010 for libspatha by  doxygen 1.6.3