51#ifndef CCXX_MISSING_H_
59#ifndef CCXX_EXCEPTION_H_
66# include <sys/types.h>
74# if __BORLANDC__ >= 0x0560
87#include <mach-o/dyld.h>
102#if !defined(__BORLANDC__) || __BORLANDC__ >= 0x0560
141 accessReadOnly = O_RDONLY,
142 accessWriteOnly= O_WRONLY,
143 accessReadWrite = O_RDWR
145 accessReadOnly = GENERIC_READ,
146 accessWriteOnly = GENERIC_WRITE,
147 accessReadWrite = GENERIC_READ | GENERIC_WRITE
172 openReadOnly = O_RDONLY,
173 openWriteOnly = O_WRONLY,
174 openReadWrite = O_RDWR,
175 openAppend = O_WRONLY | O_APPEND,
177 openSync = O_RDWR | O_SYNC,
181 openTruncate = O_RDWR | O_TRUNC
229 mappedRead = accessReadOnly,
230 mappedWrite = accessWriteOnly,
231 mappedReadWrite = accessReadWrite
265 char save_space[
sizeof(
struct dirent) +
PATH_MAX + 1];
267 struct dirent *entry;
270 WIN32_FIND_DATA data, fdata;
275 Dir(
const char *name = NULL);
320 unsigned max, current, prefixpos;
332 virtual bool filter(
const char *file,
struct stat *ino);
342 DirTree(
const char *prefix,
unsigned maxdepth);
448 {
return error(errExtended, err);};
457 {flags.thrown = !enable;};
477 {flags.temp = enable;};
571 Error open(
const char *path);
652 Error open(
const char *path);
682 {
return open(pathname);};
819 void update(
size_t offset = 0,
size_t len = 0);
847 {
return ((
char *)(fcb.
address)) + offset;};
899#if defined(HAVE_MACH_DYLD)
901#elif defined(HAVE_SHL_LOAD)
908 void loader(
const char *filename,
bool resolve);
919 {loader(filename,
true);};
921 DSO(
const char *filename,
bool resolve)
922 {loader(filename, resolve);};
924 DSO(
const char *filename)
926 DSO(
const char *filename,
bool resolve)
950 void *operator[](
const char *)
957 static void dynunload(
void)
990inline bool isDevice(
const char *path)
1002#ifdef COMMON_STD_EXCEPTION
1004class DirException :
public IOException
1007 DirException(
const String &str) : IOException(str) {};
1010class __EXPORT DSOException :
public IOException
1013 DSOException(
const String &str) : IOException(str) {};
1016class __EXPORT FileException :
public IOException
1019 FileException(
const String &str) : IOException(str) {};
1024#ifdef CCXX_NAMESPACES
The DSO dynamic loader class is used to load object files.
Definition file.h:890
bool isValid(void)
See if DSO object is valid.
static void dynunload(void)
static void setDebug(void)
Install debug handler...
DSO(const char *filename, bool resolve)
Definition file.h:921
DSO(const char *filename)
Construct and load a DSO object file.
Definition file.h:918
static DSO * getObject(const char *name)
Find a specific DSO object by filename.
virtual ~DSO()
Detach a DSO object from running memory.
const char * getError(void)
Retrieve error indicator associated with DSO failure.
Definition file.h:934
void * operator[](const char *sym)
Lookup a symbol in the loaded file.
A low level portable directory class.
Definition file.h:259
static bool create(const char *path, Attr attr=attrGroup)
Dir(const char *name=NULL)
const char * getName(void)
const char * operator++()
Definition file.h:289
const char * operator++(int)
Definition file.h:292
void open(const char *name)
bool operator!()
Definition file.h:299
static bool setPrefix(const char *path)
static bool getPrefix(char *path, size_t size=256)
static bool remove(const char *path)
A generic class to walk a hierarchical directory structure.
Definition file.h:316
virtual bool filter(const char *file, struct stat *ino)
Virtual method to filter results.
char * getPath(void)
Extract the next full pathname from the directory walk.
DirTree(const char *prefix, unsigned maxdepth)
Construct a directory tree walk starting at the specified prefix.
DirTree(unsigned maxdepth)
Construct an un-opened directory tree of a known maximum depth.
void close(void)
Close the directory path.
unsigned perform(const char *prefix)
This is used to step through the filter virtual for an entire subtree, and is used for cases where a ...
void open(const char *prefix)
Open a directory tree path.
Mapping
Definition file.h:228
enum Complete Complete
Definition file.h:239
static char * getFilename(const char *path, char *buffer, size_t size=64)
enum Open Open
Definition file.h:183
static char * getDirname(const char *path, char *buffer, size_t size=256)
Error
Definition file.h:120
@ errNotOpened
Definition file.h:122
@ errWriteInterrupted
Definition file.h:131
@ errOpenFailed
Definition file.h:126
@ errReadFailure
Definition file.h:130
@ errOpenInUse
Definition file.h:127
@ errReadInterrupted
Definition file.h:128
@ errOpenDenied
Definition file.h:125
@ errReadIncomplete
Definition file.h:129
@ errLockFailure
Definition file.h:134
@ errWriteFailure
Definition file.h:133
@ errWriteIncomplete
Definition file.h:132
@ errInitFailed
Definition file.h:124
@ errMapFailed
Definition file.h:123
Complete
Definition file.h:233
@ completionImmediate
Definition file.h:234
@ completionDelayed
Definition file.h:235
static const char * getExtension(const char *path)
enum Mapping Mapping
Definition file.h:240
Open
Definition file.h:171
static const char * getFilename(const char *path)
static char * getRealpath(const char *path, char *buffer, size_t size=256)
enum Access Access
Definition file.h:150
enum Error Error
Definition file.h:137
Attr
Definition file.h:199
enum Attr Attr
Definition file.h:213
Access
Definition file.h:139
Create and map a disk file into memory.
Definition file.h:748
void sync(char *address, size_t len)
Synchronize a segment of memory mapped from a segment fetch.
MappedFile(const char *fname, Access mode)
Open a file for mapping.
virtual ~MappedFile()
Release a mapped section of memory associated with a file.
void unlock(void)
Unlock a locked mapped portion of a file.
void release(char *address, size_t len)
Release (unmap) a memory segment.
MappedFile(const char *fname, Access mode, size_t size)
Create if not exists, and map a file of specified size into memory.
void update(char *address, size_t len)
Update a mapped region back to disk as specified by address and length.
char * fetch(off_t pos, size_t len)
Fetch and map a portion of a disk file to a logical memory block.
void update(size_t offset=0, size_t len=0)
Map a portion of the memory mapped from the file back to the file and do not wait for completion.
bool lock(void)
Lock the currently mapped portion of a file.
char * fetch(size_t offset=0)
Fetch a pointer to an offset within the memory mapped portion of the disk file.
Definition file.h:846
MappedFile(const char *fname, pos_t offset, size_t size, Access mode)
Map a portion or all of a specified file in the specified shared memory access mode.
void sync(void)
Synchronize the contents of the mapped portion of memory with the disk file and wait for completion.
size_t pageAligned(size_t size)
Compute map size to aligned page boundry.
The Mutex class is used to protect a section of code so that at any given time only a single thread c...
Definition thread.h:187
The purpose of this class is to define a base class for low level random file access that is portable...
Definition file.h:397
bool thrown
Definition file.h:414
Access access
Definition file.h:406
void setTemporary(bool enable)
Used to set the temporary attribute for the file.
Definition file.h:476
bool __EXPORT canAccess(const char *path)
char * getErrorString(void)
Return current error string.
Definition file.h:540
Error getErrorNumber(void)
Return current error id.
Definition file.h:532
time_t __EXPORT lastModified(const char *path)
bool __EXPORT isDir(const char *path)
time_t __EXPORT lastAccessed(const char *path)
char * pathname
Definition file.h:410
bool temp
Definition file.h:419
virtual Attr initialize(void)
This method is used to initialize a newly created file as indicated by the "initial" flag.
bool immediate
Definition file.h:417
Error error(char *err)
Post an extended string error message.
Definition file.h:447
bool initial(void)
This method should be called right after a RandomFile derived object has been created.
Error error(Error errid, char *errstr=NULL)
Post an error event.
bool __EXPORT isDevice(const char *path)
int fd
Definition file.h:404
RandomFile(const char *name=NULL)
Create an unopened random access file.
bool __EXPORT isFile(const char *path)
bool __EXPORT canModify(const char *path)
Error setCompletion(Complete mode)
Used to set file completion modes.
virtual Error restart(void)
This method is commonly used to close and re-open an existing database.
virtual ~RandomFile()
Destroy a random access file or it's derived class.
off_t getCapacity(void)
Get current file capacity.
unsigned count
Definition file.h:413
bool initial
Definition file.h:415
void setError(bool enable)
Used to enable or disable throwing of exceptions on errors.
Definition file.h:456
RandomFile(const RandomFile &rf)
Default copy constructor.
This class defines a database I/O file service that can be shared by multiple processes.
Definition file.h:649
Error restart(void)
Restart an existing database; close and re-open.
Definition file.h:681
virtual ~SharedFile()
Close and finish a database file.
Error update(char *address=NULL, ccxx_size_t length=0, off_t position=-1)
Update a portion of a file from physical memory.
Error append(char *address=NULL, ccxx_size_t length=0)
Add new data to the end of the file.
Error fetch(char *address=NULL, 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.
SharedFile(const SharedFile &file)
Create a shared file as a duplicate of an existing shared file.
Error clear(ccxx_size_t length=0, off_t pos=-1)
Clear a lock held from a previous fetch operation without updating.
SharedFile(const char *path)
Open or create a new database file.
This is a generic and portable string class.
Definition string.h:81
This class defines a database I/O file service that can be shared by multiple threads.
Definition file.h:566
off_t getPosition(void)
Fetch the current file position marker for this thread.
Error append(char *address=NULL, ccxx_size_t length=0)
Add new data to the end of the file.
ThreadFile(const char *path)
Open or create a new database file.
Error fetch(char *address=NULL, ccxx_size_t length=0, off_t position=-1)
Fetch a portion of the file into physical memory.
Error restart(void)
Restart an existing database; close and re-open.
Error update(char *address=NULL, ccxx_size_t length=0, off_t position=-1)
Update a portion of a file from physical memory.
virtual ~ThreadFile()
Close and finish a database file.
This class allows the creation of a thread context unique "pointer" that can be set and retrieved and...
Definition thread.h:1708
#define __EXPORT
Definition config.h:1045
GNU Common C++ exception model base classes.
#define S_IROTH
Definition file.h:192
#define caddr_t
Definition file.h:99
#define S_IRGRP
Definition file.h:190
#define S_IWOTH
Definition file.h:193
#define S_IRUSR
Definition file.h:188
#define NAME_MAX
Definition file.h:114
#define S_IWUSR
Definition file.h:189
#define S_IWGRP
Definition file.h:191
#define PATH_MAX
Definition file.h:110
substitute functions which may be missing in target platform libc.
unsigned long pos_t
Definition file.h:94
size_t ccxx_size_t
Definition file.h:100
__EXPORT AppLog & error(AppLog &sl)
Manipulator for error level.
Definition applog.h:541
int HANDLE
Definition serial.h:60
#define INVALID_HANDLE_VALUE
Definition serial.h:61
struct _fcb * next
Definition file.h:154
bool locked
Definition file.h:158
char * address
Definition file.h:155
off_t pos
Definition file.h:157
ccxx_size_t len
Definition file.h:156
Synchronization and threading services.