GNU CommonC++
|
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. More...
#include <file.h>
Public Member Functions | |
virtual | ~RandomFile () |
Destroy a random access file or it's derived class. More... | |
bool | initial (void) |
This method should be called right after a RandomFile derived object has been created. More... | |
off_t | getCapacity (void) |
Get current file capacity. More... | |
virtual Error | restart (void) |
This method is commonly used to close and re-open an existing database. More... | |
Error | getErrorNumber (void) |
Return current error id. More... | |
char * | getErrorString (void) |
Return current error string. More... | |
bool | operator! (void) |
Protected Member Functions | |
RandomFile (const char *name=NULL) | |
Create an unopened random access file. More... | |
RandomFile (const RandomFile &rf) | |
Default copy constructor. More... | |
Error | error (Error errid, char *errstr=NULL) |
Post an error event. More... | |
Error | error (char *err) |
Post an extended string error message. More... | |
void | setError (bool enable) |
Used to enable or disable throwing of exceptions on errors. More... | |
Error | setCompletion (Complete mode) |
Used to set file completion modes. More... | |
void | setTemporary (bool enable) |
Used to set the temporary attribute for the file. More... | |
virtual Attr | initialize (void) |
This method is used to initialize a newly created file as indicated by the "initial" flag. More... | |
void | final (void) |
Close the file. More... | |
![]() | |
Mutex (const char *name=NULL) | |
The mutex is always initialized as a recursive entity. More... | |
virtual | ~Mutex () |
Destroying the mutex removes any system resources associated with it. More... | |
void | nameMutex (const char *name) |
Enable setting of mutex name for deadlock debug. More... | |
void | enterMutex (void) |
Entering a Mutex locks the mutex for the current thread. More... | |
void | enter (void) |
Future abi will use enter/leave/test members. More... | |
void | leave (void) |
Future abi will use enter/leave/test members. More... | |
bool | test (void) |
Future abi will use enter/leave/test members. More... | |
bool | tryEnterMutex (void) |
Tries to lock the mutex for the current thread. More... | |
void | leaveMutex (void) |
Leaving a mutex frees that mutex for use by another thread. More... | |
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 | |
![]() | |
enum | Error { errSuccess = 0, errNotOpened, errMapFailed, errInitFailed, errOpenDenied, errOpenFailed, errOpenInUse, errReadInterrupted, errReadIncomplete, errReadFailure, errWriteInterrupted, errWriteIncomplete, errWriteFailure, errLockFailure, errExtended } |
enum | Access { accessReadOnly = O_RDONLY, accessWriteOnly = O_WRONLY, accessReadWrite = O_RDWR } |
enum | Open { openReadOnly = O_RDONLY, openWriteOnly = O_WRONLY, openReadWrite = O_RDWR, openAppend = O_WRONLY | O_APPEND, openSync = O_RDWR, openTruncate = O_RDWR | O_TRUNC } |
enum | Attr { attrInvalid = 0, attrPrivate = 0400 | 0200, attrGroup = attrPrivate | 0040 | 0020, attrPublic = attrGroup | 0004 | 0002 } |
enum | Mapping { mappedRead = accessReadOnly, mappedWrite = accessWriteOnly, mappedReadWrite = accessReadWrite } |
enum | Complete { completionImmediate, completionDelayed, completionDeferred } |
typedef enum Error | Error |
typedef enum Access | Access |
typedef enum Open | Open |
typedef enum Attr | Attr |
typedef enum Complete | Complete |
typedef enum Mapping | Mapping |
![]() | |
static const char * | getExtension (const char *path) |
static const char * | getFilename (const char *path) |
static char * | getFilename (const char *path, char *buffer, size_t size=64) |
static char * | getDirname (const char *path, char *buffer, size_t size=256) |
static char * | getRealpath (const char *path, char *buffer, size_t size=256) |
![]() | |
typedef struct ost::File::_fcb | fcb_t |
enum | Error { errSuccess = 0, errNotOpened, errMapFailed, errInitFailed, errOpenDenied, errOpenFailed, errOpenInUse, errReadInterrupted, errReadIncomplete, errReadFailure, errWriteInterrupted, errWriteIncomplete, errWriteFailure, errLockFailure, errExtended } |
enum | Access { accessReadOnly = O_RDONLY, accessWriteOnly = O_WRONLY, accessReadWrite = O_RDWR } |
enum | Open { openReadOnly = O_RDONLY, openWriteOnly = O_WRONLY, openReadWrite = O_RDWR, openAppend = O_WRONLY | O_APPEND, openSync = O_RDWR, openTruncate = O_RDWR | O_TRUNC } |
enum | Attr { attrInvalid = 0, attrPrivate = 0400 | 0200, attrGroup = attrPrivate | 0040 | 0020, attrPublic = attrGroup | 0004 | 0002 } |
enum | Mapping { mappedRead = accessReadOnly, mappedWrite = accessWriteOnly, mappedReadWrite = accessReadWrite } |
enum | Complete { completionImmediate, completionDelayed, completionDeferred } |
typedef enum Error | Error |
typedef enum Access | Access |
typedef enum Open | Open |
typedef enum Attr | Attr |
typedef enum Complete | Complete |
typedef enum Mapping | Mapping |
![]() | |
static void | setDebug (bool mode) |
Enable or disable deadlock debugging. More... | |
![]() | |
static const char * | getExtension (const char *path) |
static const char * | getFilename (const char *path) |
static char * | getFilename (const char *path, char *buffer, size_t size=64) |
static char * | getDirname (const char *path, char *buffer, size_t size=256) |
static char * | getRealpath (const char *path, char *buffer, size_t size=256) |
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.
|
protected |
Create an unopened random access file.
|
protected |
Default copy constructor.
|
virtual |
Destroy a random access file or it's derived class.
Post an error event.
errid | error code. |
errstr | error message string. |
|
inlineprotected |
Post an extended string error message.
err | error string. |
References ost::error().
|
protected |
Close the file.
off_t ost::RandomFile::getCapacity | ( | void | ) |
Get current file capacity.
|
inline |
Return current error id.
|
inline |
Return current error string.
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.
|
protectedvirtual |
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.
bool ost::RandomFile::operator! | ( | void | ) |
|
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.
Reimplemented in ost::SharedFile, and ost::ThreadFile.
Used to set file completion modes.
mode | completion mode. |
|
inlineprotected |
Used to enable or disable throwing of exceptions on errors.
enable | true if errors will be thrown. |
|
inlineprotected |
Used to set the temporary attribute for the file.
Temporary files are automatically deleted when closed.
enable | true for marking as temporary. |
|
related |
|
related |
|
related |
|
related |
|
related |
|
related |
|
related |
|
protected |
unsigned ost::RandomFile::count |
|
protected |
struct { ... } ost::RandomFile::flags |
bool ost::RandomFile::immediate |
bool ost::RandomFile::initial |
|
protected |
bool ost::RandomFile::temp |
bool ost::RandomFile::thrown |