|
ucommon
|
This class defines a database I/O file service that can be shared by multiple processes. More...
#include <file.h>


Public Member Functions | |
| Error | append (char *address=((void *) 0), ccxx_size_t length=0) |
| Add new data to the end of the file. | |
| Error | clear (ccxx_size_t length=0, off_t pos=-1) |
| Clear a lock held from a previous fetch operation without updating. | |
| Error | fetch (char *address=((void *) 0), ccxx_size_t length=0, off_t position=-1) |
| Lock and Fetch a portion of the file into physical memory. | |
| off_t | getPosition (void) |
| Fetch the current file position marker for this thread. | |
| bool | operator++ (void) |
| bool | operator-- (void) |
| Error | restart (void) |
| Restart an existing database; close and re-open. | |
| SharedFile (char *path) | |
| Open or create a new database file. | |
| SharedFile (SharedFile &file) | |
| Create a shared file as a duplicate of an existing shared file. | |
| Error | update (char *address=((void *) 0), ccxx_size_t length=0, off_t position=-1) |
| Update a portion of a file from physical memory. | |
| virtual | ~SharedFile () |
| Close and finish a database file. | |
Public Member Functions inherited from ost::RandomFile | |
| off_t | getCapacity (void) |
| Get current file capacity. | |
| Error | getErrorNumber (void) |
| Return current error id. | |
| char * | getErrorString (void) |
| Return current error string. | |
| bool | initial (void) |
| This method should be called right after a RandomFile derived object has been created. | |
| bool | operator! (void) |
| virtual | ~RandomFile () |
| Destroy a random access file or it's derived class. | |
Additional Inherited Members | |
Public Types inherited from ost::File | |
| enum | Access { accessReadOnly = 00, accessWriteOnly = 01, accessReadWrite = 02 } |
| typedef enum Access | Access |
| enum | Attr { attrInvalid = 0, attrPrivate = 0400 | 0200, attrGroup = attrPrivate | ( 0400 >> 3) | ( 0200 >> 3), attrPublic = attrGroup | ( ( 0400 >> 3) >> 3) | ( ( 0200 >> 3) >> 3) } |
| typedef enum Attr | Attr |
| enum | Complete { completionImmediate, completionDelayed, completionDeferred } |
| typedef enum Complete | Complete |
| enum | Error { errSuccess = 0, errNotOpened, errMapFailed, errInitFailed, errOpenDenied, errOpenFailed, errOpenInUse, errReadInterrupted, errReadIncomplete, errReadFailure, errWriteInterrupted, errWriteIncomplete, errWriteFailure, errLockFailure, errExtended } |
| typedef enum Error | Error |
| enum | Mapping { mappedRead = accessReadOnly, mappedWrite = accessWriteOnly, mappedReadWrite = accessReadWrite } |
| typedef enum Mapping | Mapping |
| enum | Open { openReadOnly = 00, openWriteOnly = 01, openReadWrite = 02, openAppend = 01 | 02000, openSync = 02 | 04010000, openTruncate = 02 | 01000 } |
| typedef enum Open | Open |
Static Public Member Functions inherited from ost::File | |
| static char * | getDirname (char *path, char *buffer, size_t size=4096) |
| static char * | getExtension (char *path) |
| static char * | getFilename (char *path) |
| static char * | getFilename (char *path, char *buffer, size_t size=255) |
| static char * | getRealpath (char *path, char *buffer, size_t size=4096) |
Protected Types inherited from ost::File | |
| typedef struct ost::File::_fcb | fcb_t |
Protected Member Functions inherited from ost::RandomFile | |
| Error | error (Error errid, char *errstr=((void *) 0)) |
| Post an error event. | |
| Error | error (char *err) |
| Post an extended string error message. | |
| void | final (void) |
| Close the file. | |
| virtual Attr | initialize (void) |
| This method is used to initialize a newly created file as indicated by the "initial" flag. | |
| RandomFile (char *name=((void *) 0)) | |
| Create an unopened random access file. | |
| RandomFile (RandomFile &rf) | |
| Default copy constructor. | |
| Error | setCompletion (Complete mode) |
| Used to set file completion modes. | |
| void | setError (bool enable) |
| Used to enable or disable throwing of exceptions on errors. | |
| void | setTemporary (bool enable) |
| Used to set the temporary attribute for the file. | |
Protected Attributes inherited from ost::RandomFile | |
| Access | access |
| int | fd |
| struct { | |
| unsigned count: 16 | |
| bool immediate: 1 | |
| bool initial: 1 | |
| bool temp: 1 | |
| bool thrown: 1 | |
| } | flags |
| char * | pathname |
Related Functions inherited from ost::RandomFile | |
| bool | canAccess (char *path) |
| bool | canModify (char *path) |
| bool | isDevice (char *path) |
| bool | isDir (char *path) |
| bool | isFile (char *path) |
| time_t | lastAccessed (char *path) |
| time_t | lastModified (char *path) |
This class defines a database I/O file service that can be shared by multiple processes.
Each thread should access a dup of the database object, and mutex locks can be used to preserve transaction integrety if multiple threads are used.
SharedFile is used when a database may be shared between multiple processes. SharedFile automatically applies low level byte-range "file locks", and provides an interface to fetch and release byte-range locked portions of a file.
| ost::SharedFile::SharedFile | ( | char * | path | ) |
Open or create a new database file.
You should also use Initial.
| path | pathname of database to open. |
| ost::SharedFile::SharedFile | ( | SharedFile & | file | ) |
Create a shared file as a duplicate of an existing shared file.
| file | original file. |
| Error ost::SharedFile::append | ( | char * | address = ((void *) 0), |
| ccxx_size_t | length = 0 |
||
| ) |
Add new data to the end of the file.
Locks file during append.
| address | address to use, or NULL if same as last I/O. |
| length | length to use, or 0 if same as last I/O. |
| Error ost::SharedFile::clear | ( | ccxx_size_t | length = 0, |
| off_t | pos = -1 |
||
| ) |
Clear a lock held from a previous fetch operation without updating.
| length | length to use, or 0 if same as last I/O. |
| pos | file position to use or -1 if same as last I/O. |
| Error ost::SharedFile::fetch | ( | char * | address = ((void *) 0), |
| ccxx_size_t | length = 0, |
||
| off_t | position = -1 |
||
| ) |
Lock and Fetch a portion of the file into physical memory.
This can use state information to fetch the current record multiple times.
| address | address to use, or NULL if same as last I/O. |
| length | length to use, or 0 if same as last I/O. |
| position | file position to use -1 if same as last I/O. |
| off_t ost::SharedFile::getPosition | ( | void | ) |
Fetch the current file position marker for this thread.
|
inlinevirtual |
Restart an existing database; close and re-open.
Reimplemented from ost::RandomFile.
| Error ost::SharedFile::update | ( | char * | address = ((void *) 0), |
| ccxx_size_t | length = 0, |
||
| off_t | position = -1 |
||
| ) |
Update a portion of a file from physical memory.
This can use state information to commit the last read record. The current lock is also cleared.
| address | address to use, or NULL if same as last I/O. |
| length | length to use, or 0 if same as last I/O. |
| position | file position to use or -1 if same as last I/O. |
1.8.1.2