class RandomFile

Portable random disk file access. More...

Full nameost::RandomFile
Definition#include <file.h>
Inheritsost::Mutex [public ], ost::Mutex [public ]
Inherited byMappedFile, MappedFile, SharedFile, SharedFile, ThreadFile, ThreadFile
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

Public Methods

Protected Methods

Protected Members


Detailed Description

The purpose of this class is to define a base class for low level random file access that is portable between Win32 and Posix systems. This class is a foundation both for optimized thread shared and traditional locked file access that is commonly used to build database services, rather than the standard C++ streaming file classes.

int fd

fd

[protected]

fileaccess_t access

access

[protected]

char * pathname

pathname

[protected]

 RandomFile ()

RandomFile

[protected]

Create an unopened random access file.

 RandomFile (const RandomFile &rf)

RandomFile

[protected]

Default copy constructor.

fileerror_t  Error (fileerror_t errid, char *errstr = NULL)

Error

[protected]

Post an error event.

Parameters:
errorcode.
errormessage string.

Returns: error code.

inline fileerror_t  Error (char *errstr)

Error

[protected]

Post an extended string error message.

Parameters:
errorstring.

Returns: FILE_EXTENDED_ERROR.

inline void  setError (bool enable)

setError

[protected]

Used to enable or disable throwing of exceptions on errors.

Parameters:
trueif errors will be thrown.

fileerror_t  setCompletion (filecomplete_t mode)

setCompletion

[protected]

Used to set file completion modes.

Parameters:
completionmode.

Returns: FILE_SUCCESS if okay.

inline void  setTemporary (bool enable)

setTemporary

[protected]

Used to set the temporary attribute for the file. Temporary files are automatically deleted when closed.

Parameters:
truefor marking as temporary.

fileattr_t  Initialize (void)

Initialize

[protected virtual]

This method is used to initialize a newly created file as indicated by the "initial" flag. This method also returns the file access permissions that should be associated with the file. This method should never be called directly, but is instead used to impliment the "Initial" method. Typically one would use this to build an empty database shell when a previously empty database file is created.

Returns: access, or FILE_ATTR_INVALID if should be removed.

void  Final (void)

Final

[protected]

Close the file.

 ~RandomFile ()

~RandomFile

[virtual]

Destroy a random access file or it's derived class.

bool  Initial (void)

Initial

This method should be called right after a RandomFile derived object has been created. This method will invoke initialize if the object is newly created, and set file access permissions appropriately.

Returns: true if file had to be initialized.

off_t  getCapacity (void)

getCapacity

Get current file capacity.

Returns: total file size.

fileerror_t  Restart (void)

Restart

[virtual]

This method is commonly used to close and re-open an existing database. This may be used when the database has been unlinked and an external process provides a new one to use.

inline fileerror_t  getErrorNumber (void)

getErrorNumber

Return current error id.

Returns: last error identifier set.

inline char * getErrorString (void)

getErrorString

Return current error string.

Returns: last error string set.

bool  operator! (void)

operator!

int fd

fd

[protected]

fileaccess_t access

access

[protected]

char * pathname

pathname

[protected]

 RandomFile ()

RandomFile

[protected]

Create an unopened random access file.

 RandomFile (const RandomFile &rf)

RandomFile

[protected]

Default copy constructor.

fileerror_t  Error (fileerror_t errid, char *errstr = NULL)

Error

[protected]

Post an error event.

Parameters:
errorcode.
errormessage string.

Returns: error code.

inline fileerror_t  Error (char *errstr)

Error

[protected]

Post an extended string error message.

Parameters:
errorstring.

Returns: FILE_EXTENDED_ERROR.

inline void  setError (bool enable)

setError

[protected]

Used to enable or disable throwing of exceptions on errors.

Parameters:
trueif errors will be thrown.

fileerror_t  setCompletion (filecomplete_t mode)

setCompletion

[protected]

Used to set file completion modes.

Parameters:
completionmode.

Returns: FILE_SUCCESS if okay.

inline void  setTemporary (bool enable)

setTemporary

[protected]

Used to set the temporary attribute for the file. Temporary files are automatically deleted when closed.

Parameters:
truefor marking as temporary.

fileattr_t  Initialize (void)

Initialize

[protected virtual]

This method is used to initialize a newly created file as indicated by the "initial" flag. This method also returns the file access permissions that should be associated with the file. This method should never be called directly, but is instead used to impliment the "Initial" method. Typically one would use this to build an empty database shell when a previously empty database file is created.

Returns: access, or FILE_ATTR_INVALID if should be removed.

void  Final (void)

Final

[protected]

Close the file.

 ~RandomFile ()

~RandomFile

[virtual]

Destroy a random access file or it's derived class.

bool  Initial (void)

Initial

This method should be called right after a RandomFile derived object has been created. This method will invoke initialize if the object is newly created, and set file access permissions appropriately.

Returns: true if file had to be initialized.

off_t  getCapacity (void)

getCapacity

Get current file capacity.

Returns: total file size.

fileerror_t  Restart (void)

Restart

[virtual]

This method is commonly used to close and re-open an existing database. This may be used when the database has been unlinked and an external process provides a new one to use.

inline fileerror_t  getErrorNumber (void)

getErrorNumber

Return current error id.

Returns: last error identifier set.

inline char * getErrorString (void)

getErrorString

Return current error string.

Returns: last error string set.

bool  operator! (void)

operator!