47 #ifndef CCXX_CONFIG_H_
51 #ifndef CCXX_MISSING_H_
55 #ifndef CCXX_THREAD_H_
59 #ifndef CCXX_EXCEPTION_H_
66 # include <sys/types.h>
71 # include <sys/stat.h>
72 # include <sys/mman.h>
74 # if __BORLANDC__ >= 0x0560
76 # include <sys/stat.h>
87 #include <mach-o/dyld.h>
90 #ifdef CCXX_NAMESPACES
96 #include <sys/types.h>
99 #if !defined(__BORLANDC__) || __BORLANDC__ >= 0x0560
102 typedef void* caddr_t;
138 accessReadOnly = O_RDONLY,
139 accessWriteOnly= O_WRONLY,
140 accessReadWrite = O_RDWR
142 accessReadOnly = GENERIC_READ,
143 accessWriteOnly = GENERIC_WRITE,
144 accessReadWrite = GENERIC_READ | GENERIC_WRITE
169 openReadOnly = O_RDONLY,
170 openWriteOnly = O_WRONLY,
171 openReadWrite = O_RDWR,
172 openAppend = O_WRONLY | O_APPEND,
174 openSync = O_RDWR | O_SYNC,
178 openTruncate = O_RDWR | O_TRUNC
202 #else // defined WIN32
226 mappedRead = accessReadOnly,
227 mappedWrite = accessWriteOnly,
228 mappedReadWrite = accessReadWrite
240 static const char *getExtension(
const char *path);
241 static const char *getFilename(
const char *path);
242 static char *getFilename(
const char *path,
char *buffer,
size_t size =
NAME_MAX);
243 static char *getDirname(
const char *path,
char *buffer,
size_t size =
PATH_MAX);
244 static char *getRealpath(
const char *path,
char *buffer,
size_t size =
PATH_MAX);
260 #ifdef HAVE_READDIR_R
262 char save_space[
sizeof(
struct dirent) + PATH_MAX + 1];
264 struct dirent *entry;
267 WIN32_FIND_DATA data, fdata;
272 Dir(
const char *name = NULL);
274 static bool create(
const char *path,
Attr attr = attrGroup);
275 static bool remove(
const char *path);
276 static bool setPrefix(
const char *path);
277 static bool getPrefix(
char *path,
size_t size = PATH_MAX);
279 void open(
const char *name);
284 const char *getName(
void);
292 const char *operator*();
315 char path[PATH_MAX + 1];
317 unsigned max, current, prefixpos;
329 virtual bool filter(
const char *file,
struct stat *ino);
339 DirTree(
const char *prefix,
unsigned maxdepth);
355 void open(
const char *prefix);
380 unsigned perform(
const char *prefix);
436 Error
error(Error errid,
char *errstr = NULL);
445 {
return error(errExtended, err);};
454 {flags.thrown = !enable;};
464 Error setCompletion(Complete mode);
474 {flags.temp = enable;};
487 virtual Attr initialize(
void);
515 off_t getCapacity(
void);
522 virtual Error restart(
void);
540 bool operator!(
void);
568 Error open(
const char *path);
600 Error fetch(caddr_t address = NULL, ccxx_size_t length = 0, off_t position = -1);
611 Error update(caddr_t address = NULL, ccxx_size_t length = 0, off_t position = -1);
618 Error append(caddr_t address = NULL, ccxx_size_t length = 0);
625 off_t getPosition(
void);
627 bool operator++(
void);
628 bool operator--(
void);
649 Error open(
const char *path);
679 {
return open(pathname);};
691 Error fetch(caddr_t address = NULL, ccxx_size_t length = 0, off_t position = -1);
703 Error update(caddr_t address = NULL, ccxx_size_t length = 0, off_t position = -1);
713 Error clear(ccxx_size_t length = 0, off_t pos = -1);
721 Error append(caddr_t address = NULL, ccxx_size_t length = 0);
728 off_t getPosition(
void);
730 bool operator++(
void);
731 bool operator--(
void);
806 void sync(caddr_t address,
size_t len);
816 void update(
size_t offset = 0,
size_t len = 0);
825 void update(caddr_t address,
size_t len);
833 void release(caddr_t address,
size_t len);
843 inline caddr_t
fetch(
size_t offset = 0)
844 {
return ((
char *)(fcb.
address)) + offset;};
854 caddr_t fetch(off_t pos,
size_t len);
874 size_t pageAligned(
size_t size);
896 #if defined(HAVE_MACH_DYLD)
898 #elif defined(HAVE_SHL_LOAD)
905 void loader(
const char *filename,
bool resolve);
916 {loader(filename,
true);};
918 DSO(
const char *filename,
bool resolve)
919 {loader(filename, resolve);};
921 DSO(
const char *filename)
923 DSO(
const char *filename,
bool resolve)
945 void* operator[](
const char *sym);
947 void *operator[](
const char *)
952 static void dynunload(
void);
954 static void dynunload(
void)
963 static DSO *getObject(
const char *name);
975 static void setDebug(
void);
979 bool __EXPORT isDir(
const char *path);
981 bool __EXPORT isFile(
const char *path);
984 bool __EXPORT isDevice(
const char *path);
987 inline bool isDevice(
const char *path)
991 bool __EXPORT canAccess(
const char *path);
993 bool __EXPORT canModify(
const char *path);
995 time_t
__EXPORT lastModified(
const char *path);
997 time_t
__EXPORT lastAccessed(
const char *path);
999 #ifdef COMMON_STD_EXCEPTION
1001 class DirException :
public IOException
1004 DirException(
const String &str) : IOException(str) {};
1007 class __EXPORT DSOException :
public IOException
1010 DSOException(
const String &str) : IOException(str) {};
1013 class __EXPORT FileException :
public IOException
1016 FileException(
const String &str) : IOException(str) {};
1021 #ifdef CCXX_NAMESPACES
Error error(char *err)
Post an extended string error message.
Definition: file.h:444
#define PATH_MAX
Definition: file.h:107
caddr_t address
Definition: file.h:152
bool locked
Definition: file.h:155
int fd
Definition: file.h:401
#define NAME_MAX
Definition: file.h:111
int HANDLE
Definition: serial.h:60
#define S_IRUSR
Definition: file.h:185
#define S_IRGRP
Definition: file.h:187
Open
Definition: file.h:168
#define __EXPORT
Definition: config.h:980
substitute functions which may be missing in target platform libc.
caddr_t fetch(size_t offset=0)
Fetch a pointer to an offset within the memory mapped portion of the disk file.
Definition: file.h:843
off_t pos
Definition: file.h:154
char * pathname
Definition: file.h:407
const char * operator++(int)
Definition: file.h:289
#define S_IWGRP
Definition: file.h:188
This class defines a database I/O file service that can be shared by multiple processes.
Definition: file.h:645
GNU Common C++ exception model base classes.
The purpose of this class is to define a base class for low level random file access that is portable...
Definition: file.h:393
char * getErrorString(void)
Return current error string.
Definition: file.h:537
#define INVALID_HANDLE_VALUE
Definition: serial.h:61
Synchronization and threading services.
DSO(const char *filename)
Construct and load a DSO object file.
Definition: file.h:915
Error getErrorNumber(void)
Return current error id.
Definition: file.h:529
Access access
Definition: file.h:403
unsigned long pos_t
Definition: file.h:94
#define S_IWUSR
Definition: file.h:186
void setError(bool enable)
Used to enable or disable throwing of exceptions on errors.
Definition: file.h:453
Access
Definition: file.h:136
bool operator!()
Definition: file.h:296
This class allows the creation of a thread context unique "pointer" that can be set and retrieved and...
Definition: thread.h:1707
const char * getError(void)
Retrieve error indicator associated with DSO failure.
Definition: file.h:931
struct _fcb * next
Definition: file.h:151
A generic class to walk a hierarchical directory structure.
Definition: file.h:312
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:186
The DSO dynamic loader class is used to load object files.
Definition: file.h:886
Attr
Definition: file.h:196
This class defines a database I/O file service that can be shared by multiple threads.
Definition: file.h:562
size_t ccxx_size_t
Definition: file.h:97
void setTemporary(bool enable)
Used to set the temporary attribute for the file.
Definition: file.h:473
Create and map a disk file into memory.
Definition: file.h:744
Complete
Definition: file.h:230
Mapping
Definition: file.h:225
Error restart(void)
Restart an existing database; close and re-open.
Definition: file.h:678
DSO(const char *filename, bool resolve)
Definition: file.h:918
ccxx_size_t len
Definition: file.h:153
#define S_IWOTH
Definition: file.h:190
A low level portable directory class.
Definition: file.h:255
const char * operator++()
Definition: file.h:286
#define S_IROTH
Definition: file.h:189
Error
Definition: file.h:117
__EXPORT AppLog & error(AppLog &sl)
Manipulator for error level.
Definition: applog.h:541