SYNOPSIS

#include <file.h>

Inherits ost::Mutex, and ost::File.

Inherited by ost::MappedFile, ost::SharedFile, and ost::ThreadFile.

Public Member Functions

virtual ~RandomFile ()

Destroy a random access file or it's derived class. bool initial (void)

This method should be called right after a RandomFile derived object has been created. off_t getCapacity (void)

Get current file capacity. virtual Error restart (void)

This method is commonly used to close and re-open an existing database. Error getErrorNumber (void)

Return current error id. char * getErrorString (void)

Return current error string. bool operator! (void)

Protected Member Functions

RandomFile (const char *name=NULL)

Create an unopened random access file. RandomFile (const RandomFile &rf)

Default copy constructor. Error error (Error errid, char *errstr=NULL)

Post an error event. Error error (char *err)

Post an extended string error message. void setError (bool enable)

Used to enable or disable throwing of exceptions on errors. Error setCompletion (Complete mode)

Used to set file completion modes. void setTemporary (bool enable)

Used to set the temporary attribute for the file. virtual Attr initialize (void)

This method is used to initialize a newly created file as indicated by the 'initial' flag. void final (void)

Close the file.

Protected Attributes

int fd

Access access

char * pathname

struct {

   unsigned count: 16
   bool thrown: 1
   bool initial: 1
   bool immediate: 1
   bool temp: 1

} flags

Related Functions

(Note that these are not member functions.) bool __EXPORT isDir (const char *path)

bool __EXPORT isFile (const char *path)

bool __EXPORT isDevice (const char *path)

bool __EXPORT canAccess (const char *path)

bool __EXPORT canModify (const char *path)

time_t __EXPORT lastModified (const char *path)

time_t __EXPORT lastAccessed (const char *path)

Additional Inherited 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.

Author:

David Sugar [email protected] Portable random disk file access.

Constructor & Destructor Documentation

ost::RandomFile::RandomFile (const char *name = \fCNULL\fP)\fC [protected]\fP

Create an unopened random access file.

ost::RandomFile::RandomFile (const \fBRandomFile\fP &rf)\fC [protected]\fP

Default copy constructor.

virtual ost::RandomFile::~RandomFile ()\fC [virtual]\fP

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

Member Function Documentation

\fBError\fP ost::RandomFile::error (\fBError\fPerrid, char *errstr = \fCNULL\fP)\fC [protected]\fP

Post an error event.

Returns:

error code.

Parameters:

errid error code.

errstr error message string.

\fBError\fP ost::RandomFile::error (char *err)\fC [inline]\fP, \fC [protected]\fP

Post an extended string error message.

Returns:

errExtended.

Parameters:

err error string.

References ost::error().

void ost::RandomFile::final (void)\fC [protected]\fP

Close the file.

off_t ost::RandomFile::getCapacity (void)

Get current file capacity.

Returns:

total file size.

\fBError\fP ost::RandomFile::getErrorNumber (void)\fC [inline]\fP

Return current error id.

Returns:

last error identifier set.

char* ost::RandomFile::getErrorString (void)\fC [inline]\fP

Return current error string.

Returns:

last error string set.

bool ost::RandomFile::initial (void)

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.

virtual \fBAttr\fP ost::RandomFile::initialize (void)\fC [protected]\fP, \fC [virtual]\fP

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 attrInvalid if should be removed.

bool ost::RandomFile::operator! (void)

virtual \fBError\fP ost::RandomFile::restart (void)\fC [virtual]\fP

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.

Reimplemented in ost::SharedFile, and ost::ThreadFile.

\fBError\fP ost::RandomFile::setCompletion (\fBComplete\fPmode)\fC [protected]\fP

Used to set file completion modes.

Returns:

errSuccess if okay.

Parameters:

mode completion mode.

void ost::RandomFile::setError (boolenable)\fC [inline]\fP, \fC [protected]\fP

Used to enable or disable throwing of exceptions on errors.

Parameters:

enable true if errors will be thrown.

void ost::RandomFile::setTemporary (boolenable)\fC [inline]\fP, \fC [protected]\fP

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

Parameters:

enable true for marking as temporary.

Friends And Related Function Documentation

bool \fB__EXPORT\fP canAccess (const char *path)\fC [related]\fP

bool \fB__EXPORT\fP canModify (const char *path)\fC [related]\fP

bool \fB__EXPORT\fP isDevice (const char *path)\fC [related]\fP

bool \fB__EXPORT\fP isDir (const char *path)\fC [related]\fP

bool \fB__EXPORT\fP isFile (const char *path)\fC [related]\fP

time_t \fB__EXPORT\fP lastAccessed (const char *path)\fC [related]\fP

time_t \fB__EXPORT\fP lastModified (const char *path)\fC [related]\fP

Member Data Documentation

\fBAccess\fP ost::RandomFile::access\fC [protected]\fP

unsigned ost::RandomFile::count

int ost::RandomFile::fd\fC [protected]\fP

struct { ... } ost::RandomFile::flags\fC [protected]\fP

bool ost::RandomFile::immediate

bool ost::RandomFile::initial

char* ost::RandomFile::pathname\fC [protected]\fP

bool ost::RandomFile::temp

bool ost::RandomFile::thrown

Author

Generated automatically by Doxygen for GNU CommonC++ from the source code.