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 99 #define caddr_t char * 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
205 #else // defined WIN32 229 mappedRead = accessReadOnly,
230 mappedWrite = accessWriteOnly,
231 mappedReadWrite = accessReadWrite
243 static const char *getExtension(
const char *path);
244 static const char *getFilename(
const char *path);
245 static char *getFilename(
const char *path,
char *buffer,
size_t size =
NAME_MAX);
246 static char *getDirname(
const char *path,
char *buffer,
size_t size =
PATH_MAX);
247 static char *getRealpath(
const char *path,
char *buffer,
size_t size =
PATH_MAX);
263 #ifdef HAVE_READDIR_R 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);
277 static bool create(
const char *path,
Attr attr = attrGroup);
278 static bool remove(
const char *path);
279 static bool setPrefix(
const char *path);
280 static bool getPrefix(
char *path,
size_t size = PATH_MAX);
282 void open(
const char *name);
287 const char *getName(
void);
295 const char *operator*();
318 char path[PATH_MAX + 1];
320 unsigned max, current, prefixpos;
332 virtual bool filter(
const char *file,
struct stat *ino);
342 DirTree(
const char *prefix,
unsigned maxdepth);
358 void open(
const char *prefix);
383 unsigned perform(
const char *prefix);
448 {
return error(errExtended, err);};
457 {flags.thrown = !enable;};
477 {flags.temp = enable;};
490 virtual Attr initialize(
void);
518 off_t getCapacity(
void);
525 virtual Error restart(
void);
543 bool operator!(
void);
571 Error open(
const char *path);
603 Error fetch(caddr_t address = NULL, ccxx_size_t length = 0, off_t position = -1);
614 Error update(caddr_t address = NULL, ccxx_size_t length = 0, off_t position = -1);
621 Error append(caddr_t address = NULL, ccxx_size_t length = 0);
628 off_t getPosition(
void);
630 bool operator++(
void);
631 bool operator--(
void);
652 Error open(
const char *path);
682 {
return open(pathname);};
694 Error fetch(caddr_t address = NULL, ccxx_size_t length = 0, off_t position = -1);
706 Error update(caddr_t address = NULL, ccxx_size_t length = 0, off_t position = -1);
716 Error clear(ccxx_size_t length = 0, off_t pos = -1);
724 Error append(caddr_t address = NULL, ccxx_size_t length = 0);
731 off_t getPosition(
void);
733 bool operator++(
void);
734 bool operator--(
void);
809 void sync(caddr_t address,
size_t len);
819 void update(
size_t offset = 0,
size_t len = 0);
828 void update(caddr_t address,
size_t len);
836 void release(caddr_t address,
size_t len);
846 inline caddr_t
fetch(
size_t offset = 0)
847 {
return ((
char *)(fcb.
address)) + offset;};
857 caddr_t fetch(off_t pos,
size_t len);
877 size_t pageAligned(
size_t size);
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)
948 void* operator[](
const char *sym);
950 void *operator[](
const char *)
955 static void dynunload(
void);
957 static void dynunload(
void)
966 static DSO *getObject(
const char *name);
978 static void setDebug(
void);
982 bool __EXPORT isDir(
const char *path);
984 bool __EXPORT isFile(
const char *path);
987 bool __EXPORT isDevice(
const char *path);
990 inline bool isDevice(
const char *path)
994 bool __EXPORT canAccess(
const char *path);
996 bool __EXPORT canModify(
const char *path);
998 time_t
__EXPORT lastModified(
const char *path);
1000 time_t
__EXPORT lastAccessed(
const char *path);
1002 #ifdef COMMON_STD_EXCEPTION 1004 class DirException :
public IOException
1007 DirException(
const String &str) : IOException(str) {};
1010 class __EXPORT DSOException :
public IOException
1013 DSOException(
const String &str) : IOException(str) {};
1016 class __EXPORT FileException :
public IOException
1019 FileException(
const String &str) : IOException(str) {};
1024 #ifdef CCXX_NAMESPACES
Error error(char *err)
Post an extended string error message.
Definition: file.h:447
#define PATH_MAX
Definition: file.h:110
bool initial
Definition: file.h:415
This is a generic and portable string class.
Definition: string.h:77
bool locked
Definition: file.h:158
int fd
Definition: file.h:404
#define NAME_MAX
Definition: file.h:114
#define caddr_t
Definition: file.h:99
int HANDLE
Definition: serial.h:60
#define S_IRUSR
Definition: file.h:188
#define S_IRGRP
Definition: file.h:190
Open
Definition: file.h:171
#define __EXPORT
Definition: config.h:980
substitute functions which may be missing in target platform libc.
off_t pos
Definition: file.h:157
char * pathname
Definition: file.h:410
const char * operator++(int)
Definition: file.h:292
#define S_IWGRP
Definition: file.h:191
This class defines a database I/O file service that can be shared by multiple processes.
Definition: file.h:648
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:396
char * getErrorString(void)
Return current error string.
Definition: file.h:540
#define INVALID_HANDLE_VALUE
Definition: serial.h:61
Synchronization and threading services.
unsigned count
Definition: file.h:413
DSO(const char *filename)
Construct and load a DSO object file.
Definition: file.h:918
Error getErrorNumber(void)
Return current error id.
Definition: file.h:532
Access access
Definition: file.h:406
bool temp
Definition: file.h:419
unsigned long pos_t
Definition: file.h:94
#define S_IWUSR
Definition: file.h:189
void setError(bool enable)
Used to enable or disable throwing of exceptions on errors.
Definition: file.h:456
Access
Definition: file.h:139
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
bool operator!()
Definition: file.h:299
char * address
Definition: file.h:155
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:934
struct _fcb * next
Definition: file.h:154
A generic class to walk a hierarchical directory structure.
Definition: file.h:315
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:889
Attr
Definition: file.h:199
bool thrown
Definition: file.h:414
This class defines a database I/O file service that can be shared by multiple threads.
Definition: file.h:565
size_t ccxx_size_t
Definition: file.h:100
void setTemporary(bool enable)
Used to set the temporary attribute for the file.
Definition: file.h:476
Create and map a disk file into memory.
Definition: file.h:747
Complete
Definition: file.h:233
Mapping
Definition: file.h:228
Error restart(void)
Restart an existing database; close and re-open.
Definition: file.h:681
DSO(const char *filename, bool resolve)
Definition: file.h:921
ccxx_size_t len
Definition: file.h:156
bool immediate
Definition: file.h:417
#define S_IWOTH
Definition: file.h:193
A low level portable directory class.
Definition: file.h:258
const char * operator++()
Definition: file.h:289
#define S_IROTH
Definition: file.h:192
Error
Definition: file.h:120
__EXPORT AppLog & error(AppLog &sl)
Manipulator for error level.
Definition: applog.h:541