GNU CommonC++
file.h
Go to the documentation of this file.
1 // Copyright (C) 1999-2005 Open Source Telecom Corporation.
2 // Copyright (C) 2006-2010 David Sugar, Tycho Softworks.
3 //
4 // This program is free software; you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation; either version 2 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 //
18 // As a special exception, you may use this file as part of a free software
19 // library without restriction. Specifically, if other files instantiate
20 // templates or use macros or inline functions from this file, or you compile
21 // this file and link it with other files to produce an executable, this
22 // file does not by itself cause the resulting executable to be covered by
23 // the GNU General Public License. This exception does not however
24 // invalidate any other reasons why the executable file might be covered by
25 // the GNU General Public License.
26 //
27 // This exception applies only to the code released under the name GNU
28 // Common C++. If you copy code from other releases into a copy of GNU
29 // Common C++, as the General Public License permits, the exception does
30 // not apply to the code that you add in this way. To avoid misleading
31 // anyone as to the status of such modified files, you must delete
32 // this exception notice from them.
33 //
34 // If you write modifications of your own for GNU Common C++, it is your choice
35 // whether to permit this exception to apply to your modifications.
36 // If you do not wish that, delete this exception notice.
37 //
38 
44 #ifndef CCXX_FILE_H_
45 #define CCXX_FILE_H_
46 
47 #ifndef CCXX_CONFIG_H_
48 #include <cc++/config.h>
49 #endif
50 
51 #ifndef CCXX_MISSING_H_
52 #include <cc++/missing.h>
53 #endif
54 
55 #ifndef CCXX_THREAD_H_
56 #include <cc++/thread.h>
57 #endif
58 
59 #ifndef CCXX_EXCEPTION_H_
60 #include <cc++/exception.h>
61 #endif
62 
63 #ifndef WIN32
64 # ifdef __BORLANDC__
65 # include <stdio.h>
66 # include <sys/types.h>
67 # else
68 # include <cstdio>
69 # endif
70 # include <dirent.h>
71 # include <sys/stat.h>
72 # include <sys/mman.h>
73 #else
74 # if __BORLANDC__ >= 0x0560
75 # include <dirent.h>
76 # include <sys/stat.h>
77 # else
78 # include <direct.h>
79 # endif
80 #endif
81 
82 #ifdef HAVE_SHL_LOAD
83 #include <dl.h>
84 #endif
85 
86 #ifdef HAVE_MACH_DYLD
87 #include <mach-o/dyld.h>
88 #endif
89 
90 #ifdef CCXX_NAMESPACES
91 namespace ost {
92 #endif
93 
94 typedef unsigned long pos_t;
95 #ifndef WIN32
96 // use a define so that if the sys/types.h header already defines caddr_t
97 // as it may on BSD systems, we do not break it by redefining again.
98 #undef caddr_t
99 #define caddr_t char *
100 typedef size_t ccxx_size_t;
101 #else
102 #if !defined(__BORLANDC__) || __BORLANDC__ >= 0x0560
103 typedef LONG off_t;
104 #endif
105 typedef void* caddr_t;
106 typedef DWORD ccxx_size_t;
107 #endif
108 
109 #ifndef PATH_MAX
110 #define PATH_MAX 256
111 #endif
112 
113 #ifndef NAME_MAX
114 #define NAME_MAX 64
115 #endif
116 
118 {
119 public:
120  enum Error {
121  errSuccess = 0,
135  errExtended
136  };
137  typedef enum Error Error;
138 
139  enum Access {
140 #ifndef WIN32
141  accessReadOnly = O_RDONLY,
142  accessWriteOnly= O_WRONLY,
143  accessReadWrite = O_RDWR
144 #else
145  accessReadOnly = GENERIC_READ,
146  accessWriteOnly = GENERIC_WRITE,
147  accessReadWrite = GENERIC_READ | GENERIC_WRITE
148 #endif
149  };
150  typedef enum Access Access;
151 
152 protected:
153  typedef struct _fcb {
154  struct _fcb *next;
157  off_t pos;
158  bool locked;
159  } fcb_t;
160 
161 public:
162 #ifdef WIN32
163  enum Open {
164  openReadOnly, // = FILE_OPEN_READONLY,
165  openWriteOnly, // = FILE_OPEN_WRITEONLY,
166  openReadWrite, // = FILE_OPEN_READWRITE,
167  openAppend, // = FILE_OPEN_APPEND,
168  openTruncate // = FILE_OPEN_TRUNCATE
169  };
170  #else
171  enum Open {
172  openReadOnly = O_RDONLY,
173  openWriteOnly = O_WRONLY,
174  openReadWrite = O_RDWR,
175  openAppend = O_WRONLY | O_APPEND,
176 #ifdef O_SYNC
177  openSync = O_RDWR | O_SYNC,
178 #else
179  openSync = O_RDWR,
180 #endif
181  openTruncate = O_RDWR | O_TRUNC
182  };
183  typedef enum Open Open;
184 
185 /* to be used in future */
186 
187 #ifndef S_IRUSR
188 #define S_IRUSR 0400
189 #define S_IWUSR 0200
190 #define S_IRGRP 0040
191 #define S_IWGRP 0020
192 #define S_IROTH 0004
193 #define S_IWOTH 0002
194 #endif
195 
196 #endif // !WIN32
197 
198 #ifndef WIN32
199  enum Attr {
200  attrInvalid = 0,
201  attrPrivate = S_IRUSR | S_IWUSR,
202  attrGroup = attrPrivate | S_IRGRP | S_IWGRP,
203  attrPublic = attrGroup | S_IROTH | S_IWOTH
204  };
205  #else // defined WIN32
206  enum Attr {
207  attrInvalid=0,
208  attrPrivate,
209  attrGroup,
210  attrPublic
211  };
212 #endif // !WIN32
213  typedef enum Attr Attr;
214 
215 #ifdef WIN32
216  enum Complete {
217  completionImmediate, // = FILE_COMPLETION_IMMEDIATE,
218  completionDelayed, // = FILE_COMPLETION_DELAYED,
219  completionDeferred // = FILE_COMPLETION_DEFERRED
220  };
221 
222  enum Mapping {
223  mappedRead,
224  mappedWrite,
225  mappedReadWrite
226  };
227 #else
228  enum Mapping {
229  mappedRead = accessReadOnly,
230  mappedWrite = accessWriteOnly,
231  mappedReadWrite = accessReadWrite
232  };
233  enum Complete {
236  completionDeferred
237  };
238 #endif
239  typedef enum Complete Complete;
240  typedef enum Mapping Mapping;
241 
242 public:
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);
248 };
249 
258 class __EXPORT Dir : public File
259 {
260 private:
261 #ifndef WIN32
262  DIR *dir;
263 #ifdef HAVE_READDIR_R
264  struct dirent *save;
265  char save_space[sizeof(struct dirent) + PATH_MAX + 1];
266 #endif
267  struct dirent *entry;
268 #else
269  HANDLE hDir;
270  WIN32_FIND_DATA data, fdata;
271  char *name;
272 #endif
273 
274 public:
275  Dir(const char *name = NULL);
276 
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);
281 
282  void open(const char *name);
283  void close(void);
284 
285  virtual ~Dir();
286 
287  const char *getName(void);
288 
289  const char *operator++()
290  {return getName();};
291 
292  const char *operator++(int)
293  {return getName();};
294 
295  const char *operator*();
296 
297  bool rewind(void);
298 
299  bool operator!()
300 #ifndef WIN32
301  {return !dir;};
302 #else
303  {return hDir != INVALID_HANDLE_VALUE;};
304 #endif
305 
306  bool isValid(void);
307 };
308 
316 {
317 private:
318  char path[PATH_MAX + 1];
319  Dir *dir;
320  unsigned max, current, prefixpos;
321 
322 protected:
332  virtual bool filter(const char *file, struct stat *ino);
333 
334 public:
342  DirTree(const char *prefix, unsigned maxdepth);
343 
349  DirTree(unsigned maxdepth);
350 
351  virtual ~DirTree();
352 
358  void open(const char *prefix);
359 
363  void close(void);
364 
372  char *getPath(void);
373 
383  unsigned perform(const char *prefix);
384 };
385 
396 class __EXPORT RandomFile : protected Mutex, public File
397 {
398 private:
399  Error errid;
400  char *errstr;
401 
402 protected:
403 #ifndef WIN32
404  int fd;
405  // FIXME: WIN32 as no access member
406  Access access;
407 #else
408  HANDLE fd;
409 #endif
410  char *pathname;
411 
412  struct {
413  unsigned count : 16;
414  bool thrown : 1;
415  bool initial : 1;
416 #ifndef WIN32
417  bool immediate : 1;
418 #endif
419  bool temp : 1;
420  } flags;
421 
425  RandomFile(const char *name = NULL);
426 
430  RandomFile(const RandomFile &rf);
431 
439  Error error(Error errid, char *errstr = NULL);
440 
447  inline Error error(char *err)
448  {return error(errExtended, err);};
449 
456  inline void setError(bool enable)
457  {flags.thrown = !enable;};
458 
459 #ifndef WIN32
460 
467  Error setCompletion(Complete mode);
468 #endif
469 
476  inline void setTemporary(bool enable)
477  {flags.temp = enable;};
478 
490  virtual Attr initialize(void);
491 
495  void final(void);
496 
497 public:
501  virtual ~RandomFile();
502 
511  bool initial(void);
512 
518  off_t getCapacity(void);
519 
525  virtual Error restart(void);
526 
532  inline Error getErrorNumber(void)
533  {return errid;};
534 
540  inline char *getErrorString(void)
541  {return errstr;};
542 
543  bool operator!(void);
544 };
545 
566 {
567 private:
568  ThreadKey state;
569  fcb_t *first;
570  fcb_t *getFCB(void);
571  Error open(const char *path);
572 
573 public:
580  ThreadFile(const char *path);
581 
585  virtual ~ThreadFile();
586 
592  Error restart(void);
593 
603  Error fetch(caddr_t address = NULL, ccxx_size_t length = 0, off_t position = -1);
604 
614  Error update(caddr_t address = NULL, ccxx_size_t length = 0, off_t position = -1);
615 
621  Error append(caddr_t address = NULL, ccxx_size_t length = 0);
622 
628  off_t getPosition(void);
629 
630  bool operator++(void);
631  bool operator--(void);
632 };
633 
649 {
650 private:
651  fcb_t fcb;
652  Error open(const char *path);
653 
654 public:
661  SharedFile(const char *path);
662 
669  SharedFile(const SharedFile &file);
670 
674  virtual ~SharedFile();
675 
682  {return open(pathname);};
683 
694  Error fetch(caddr_t address = NULL, ccxx_size_t length = 0, off_t position = -1);
695 
706  Error update(caddr_t address = NULL, ccxx_size_t length = 0, off_t position = -1);
707 
716  Error clear(ccxx_size_t length = 0, off_t pos = -1);
717 
724  Error append(caddr_t address = NULL, ccxx_size_t length = 0);
725 
731  off_t getPosition(void);
732 
733  bool operator++(void);
734  bool operator--(void);
735 };
736 
748 {
749 private:
750  fcb_t fcb;
751  int prot;
752 #ifdef WIN32
753  HANDLE map;
754  char mapname[64];
755 #endif
756 
757 public:
765  MappedFile(const char *fname, Access mode);
766 
775  MappedFile(const char *fname, Access mode, size_t size);
776 
787  MappedFile(const char *fname, pos_t offset, size_t size, Access mode);
788 
793  virtual ~MappedFile();
794 
795  // FIXME: not use library function in header ??
801  void sync(void);
802 
809  void sync(caddr_t address, size_t len);
810 
819  void update(size_t offset = 0, size_t len = 0);
820 
828  void update(caddr_t address, size_t len);
829 
836  void release(caddr_t address, size_t len);
837 
846  inline caddr_t fetch(size_t offset = 0)
847  {return ((char *)(fcb.address)) + offset;};
848 
857  caddr_t fetch(off_t pos, size_t len);
858 
864  bool lock(void);
865 
869  void unlock(void);
870 
877  size_t pageAligned(size_t size);
878 };
879 
880 
890 {
891 private:
892  const char *err;
893 #ifdef HAVE_MODULES
894  static Mutex mutex;
895  static DSO *first;
896  static DSO *last;
897  DSO *next, *prev;
898  const char *id;
899 #if defined(HAVE_MACH_DYLD)
900  NSModule oModule;
901 #elif defined(HAVE_SHL_LOAD)
902  shl_t image;
903 #elif defined(WIN32)
904  HINSTANCE hImage;
905 #else
906  void *image;
907 #endif
908  void loader(const char *filename, bool resolve);
909 #endif
910 
911 public:
917 #ifdef HAVE_MODULES
918  DSO(const char *filename)
919  {loader(filename, true);};
920 
921  DSO(const char *filename, bool resolve)
922  {loader(filename, resolve);};
923 #else
924  DSO(const char *filename)
925  {throw this;};
926  DSO(const char *filename, bool resolve)
927  {throw this;};
928 #endif
929 
934  inline const char *getError(void)
935  {return err;};
936 
940 #ifdef HAVE_MODULES
941  virtual ~DSO();
942 #endif
943 
947 #ifdef HAVE_MODULES
948  void* operator[](const char *sym);
949 #else
950  void *operator[](const char *)
951  {return NULL;};
952 #endif
953 
954 #ifdef HAVE_MODULES
955  static void dynunload(void);
956 #else
957  static void dynunload(void)
958  {return;};
959 #endif
960 
966  static DSO *getObject(const char *name);
967 
973  bool isValid(void);
974 
978  static void setDebug(void);
979 };
980 
982 bool __EXPORT isDir(const char *path);
984 bool __EXPORT isFile(const char *path);
985 #ifndef WIN32
986 
987 bool __EXPORT isDevice(const char *path);
988 #else
989 
990 inline bool isDevice(const char *path)
991 { return false; }
992 #endif
993 
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);
1001 
1002 #ifdef COMMON_STD_EXCEPTION
1003 
1004 class DirException : public IOException
1005 {
1006 public:
1007  DirException(const String &str) : IOException(str) {};
1008 };
1009 
1010 class __EXPORT DSOException : public IOException
1011 {
1012 public:
1013  DSOException(const String &str) : IOException(str) {};
1014 };
1015 
1016 class __EXPORT FileException : public IOException
1017 {
1018 public:
1019  FileException(const String &str) : IOException(str) {};
1020 };
1021 
1022 #endif
1023 
1024 #ifdef CCXX_NAMESPACES
1025 }
1026 #endif
1027 
1028 #endif
1029 
ost::MappedFile::fetch
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
ost::DSO::DSO
DSO(const char *filename)
Construct and load a DSO object file.
Definition: file.h:918
ost::File::Attr
Attr
Definition: file.h:199
ost::SharedFile::SharedFile
SharedFile(const char *path)
Open or create a new database file.
ost::SharedFile::restart
Error restart(void)
Restart an existing database; close and re-open.
Definition: file.h:681
ost::RandomFile::restart
virtual Error restart(void)
This method is commonly used to close and re-open an existing database.
ost::File::Complete
Complete
Definition: file.h:233
S_IWUSR
#define S_IWUSR
Definition: file.h:189
ost::DSO::setDebug
static void setDebug(void)
Install debug handler...
ost::ThreadFile::update
Error update(char *address=NULL, ccxx_size_t length=0, off_t position=-1)
Update a portion of a file from physical memory.
ost::SharedFile::operator++
bool operator++(void)
ost::File::Access
Access
Definition: file.h:139
ost::MappedFile::MappedFile
MappedFile(const char *fname, Access mode)
Open a file for mapping.
ost::RandomFile::RandomFile
RandomFile(const RandomFile &rf)
Default copy constructor.
ost::MappedFile::lock
bool lock(void)
Lock the currently mapped portion of a file.
ost::RandomFile::getErrorString
char * getErrorString(void)
Return current error string.
Definition: file.h:540
ost::MappedFile::sync
void sync(char *address, size_t len)
Synchronize a segment of memory mapped from a segment fetch.
ost::Dir::rewind
bool rewind(void)
ost::RandomFile::count
unsigned count
Definition: file.h:413
ost::Dir::Dir
Dir(const char *name=NULL)
ost::DSO::DSO
DSO(const char *filename, bool resolve)
Definition: file.h:921
ost::DirTree::filter
virtual bool filter(const char *file, struct stat *ino)
Virtual method to filter results.
ost::SharedFile
This class defines a database I/O file service that can be shared by multiple processes.
Definition: file.h:649
INVALID_HANDLE_VALUE
#define INVALID_HANDLE_VALUE
Definition: serial.h:61
ost::RandomFile::lastModified
time_t __EXPORT lastModified(const char *path)
S_IWGRP
#define S_IWGRP
Definition: file.h:191
ost::SharedFile::getPosition
off_t getPosition(void)
Fetch the current file position marker for this thread.
ost::SharedFile::clear
Error clear(ccxx_size_t length=0, off_t pos=-1)
Clear a lock held from a previous fetch operation without updating.
ost::File
Definition: file.h:118
ost::RandomFile::isDir
bool __EXPORT isDir(const char *path)
HANDLE
int HANDLE
Definition: serial.h:60
ost::SharedFile::~SharedFile
virtual ~SharedFile()
Close and finish a database file.
ost::File::Open
Open
Definition: file.h:171
ost::File::errOpenInUse
@ errOpenInUse
Definition: file.h:127
ost::RandomFile::RandomFile
RandomFile(const char *name=NULL)
Create an unopened random access file.
ost::MappedFile::MappedFile
MappedFile(const char *fname, Access mode, size_t size)
Create if not exists, and map a file of specified size into memory.
ost::SharedFile::SharedFile
SharedFile(const SharedFile &file)
Create a shared file as a duplicate of an existing shared file.
ost::Mutex
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
ost::DirTree::DirTree
DirTree(const char *prefix, unsigned maxdepth)
Construct a directory tree walk starting at the specified prefix.
ost::ThreadFile::restart
Error restart(void)
Restart an existing database; close and re-open.
ost::RandomFile::initial
bool initial
Definition: file.h:415
ost::RandomFile::temp
bool temp
Definition: file.h:419
ost::error
__EXPORT AppLog & error(AppLog &sl)
Manipulator for error level.
Definition: applog.h:541
ost::File::getFilename
static const char * getFilename(const char *path)
ost::DSO::dynunload
static void dynunload(void)
caddr_t
#define caddr_t
Definition: file.h:99
ost::DirTree::perform
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 ...
ost::RandomFile::canAccess
bool __EXPORT canAccess(const char *path)
ost::Dir::operator!
bool operator!()
Definition: file.h:299
ost::SharedFile::update
Error update(char *address=NULL, ccxx_size_t length=0, off_t position=-1)
Update a portion of a file from physical memory.
ost::File::Error
Error
Definition: file.h:120
ost::RandomFile::canModify
bool __EXPORT canModify(const char *path)
ost::DirTree
A generic class to walk a hierarchical directory structure.
Definition: file.h:316
ost::Dir::operator*
const char * operator*()
S_IROTH
#define S_IROTH
Definition: file.h:192
ost::File::getRealpath
static char * getRealpath(const char *path, char *buffer, size_t size=256)
S_IRUSR
#define S_IRUSR
Definition: file.h:188
ost::ThreadFile::operator++
bool operator++(void)
S_IWOTH
#define S_IWOTH
Definition: file.h:193
ost::MappedFile::update
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.
ost::ThreadFile::~ThreadFile
virtual ~ThreadFile()
Close and finish a database file.
ost::Dir::setPrefix
static bool setPrefix(const char *path)
ost::RandomFile::isFile
bool __EXPORT isFile(const char *path)
ost::File::_fcb::locked
bool locked
Definition: file.h:158
ost::Dir
A low level portable directory class.
Definition: file.h:259
ost::DSO
The DSO dynamic loader class is used to load object files.
Definition: file.h:890
__EXPORT
#define __EXPORT
Definition: config.h:979
ost::RandomFile::error
Error error(Error errid, char *errstr=NULL)
Post an error event.
ost::ThreadFile::getPosition
off_t getPosition(void)
Fetch the current file position marker for this thread.
ost::MappedFile::~MappedFile
virtual ~MappedFile()
Release a mapped section of memory associated with a file.
S_IRGRP
#define S_IRGRP
Definition: file.h:190
ost::MappedFile::fetch
char * fetch(off_t pos, size_t len)
Fetch and map a portion of a disk file to a logical memory block.
ost::Dir::~Dir
virtual ~Dir()
ost::DirTree::close
void close(void)
Close the directory path.
ost::SharedFile::append
Error append(char *address=NULL, ccxx_size_t length=0)
Add new data to the end of the file.
ost::MappedFile::pageAligned
size_t pageAligned(size_t size)
Compute map size to aligned page boundry.
ost::ThreadFile::operator--
bool operator--(void)
ost::RandomFile::operator!
bool operator!(void)
ost::File::getDirname
static char * getDirname(const char *path, char *buffer, size_t size=256)
ost::Dir::getPrefix
static bool getPrefix(char *path, size_t size=256)
ost::File::errReadIncomplete
@ errReadIncomplete
Definition: file.h:129
ost::File::_fcb::pos
off_t pos
Definition: file.h:157
ost::Dir::operator++
const char * operator++()
Definition: file.h:289
ost::RandomFile::setError
void setError(bool enable)
Used to enable or disable throwing of exceptions on errors.
Definition: file.h:456
ost::SharedFile::operator--
bool operator--(void)
ost::File::errOpenDenied
@ errOpenDenied
Definition: file.h:125
ost::ThreadFile::append
Error append(char *address=NULL, ccxx_size_t length=0)
Add new data to the end of the file.
ost::RandomFile::~RandomFile
virtual ~RandomFile()
Destroy a random access file or it's derived class.
ost::MappedFile::sync
void sync(void)
Synchronize the contents of the mapped portion of memory with the disk file and wait for completion.
ost::SharedFile::fetch
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.
ost::Dir::isValid
bool isValid(void)
ost::MappedFile::unlock
void unlock(void)
Unlock a locked mapped portion of a file.
ost::DSO::getError
const char * getError(void)
Retrieve error indicator associated with DSO failure.
Definition: file.h:934
ost::Dir::open
void open(const char *name)
ost::pos_t
unsigned long pos_t
Definition: file.h:94
ost::DirTree::DirTree
DirTree(unsigned maxdepth)
Construct an un-opened directory tree of a known maximum depth.
ost::File::getExtension
static const char * getExtension(const char *path)
ost::MappedFile::update
void update(char *address, size_t len)
Update a mapped region back to disk as specified by address and length.
ost::DirTree::open
void open(const char *prefix)
Open a directory tree path.
ost::Dir::remove
static bool remove(const char *path)
ost::File::errMapFailed
@ errMapFailed
Definition: file.h:123
ost::ccxx_size_t
size_t ccxx_size_t
Definition: file.h:100
ost::DirTree::~DirTree
virtual ~DirTree()
ost::File::getFilename
static char * getFilename(const char *path, char *buffer, size_t size=64)
missing.h
substitute functions which may be missing in target platform libc.
ost::ThreadKey
This class allows the creation of a thread context unique "pointer" that can be set and retrieved and...
Definition: thread.h:1708
ost::RandomFile::fd
int fd
Definition: file.h:404
ost::Dir::getName
const char * getName(void)
ost
Definition: address.h:64
ost::RandomFile::initial
bool initial(void)
This method should be called right after a RandomFile derived object has been created.
ost::File::errOpenFailed
@ errOpenFailed
Definition: file.h:126
ost::Dir::create
static bool create(const char *path, Attr attr=attrGroup)
ost::MappedFile::MappedFile
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.
ost::DSO::operator[]
void * operator[](const char *sym)
Lookup a symbol in the loaded file.
ost::DSO::~DSO
virtual ~DSO()
Detach a DSO object from running memory.
ost::ThreadFile::ThreadFile
ThreadFile(const char *path)
Open or create a new database file.
ost::RandomFile::setTemporary
void setTemporary(bool enable)
Used to set the temporary attribute for the file.
Definition: file.h:476
NAME_MAX
#define NAME_MAX
Definition: file.h:114
ost::File::errReadInterrupted
@ errReadInterrupted
Definition: file.h:128
ost::File::_fcb::next
struct _fcb * next
Definition: file.h:154
ost::DSO::isValid
bool isValid(void)
See if DSO object is valid.
ost::ThreadFile
This class defines a database I/O file service that can be shared by multiple threads.
Definition: file.h:566
ost::DirTree::getPath
char * getPath(void)
Extract the next full pathname from the directory walk.
ost::RandomFile::getErrorNumber
Error getErrorNumber(void)
Return current error id.
Definition: file.h:532
ost::RandomFile::immediate
bool immediate
Definition: file.h:417
ost::RandomFile::thrown
bool thrown
Definition: file.h:414
ost::RandomFile::getCapacity
off_t getCapacity(void)
Get current file capacity.
config.h
ost::File::errWriteFailure
@ errWriteFailure
Definition: file.h:133
ost::File::errLockFailure
@ errLockFailure
Definition: file.h:134
exception.h
GNU Common C++ exception model base classes.
ost::File::errInitFailed
@ errInitFailed
Definition: file.h:124
ost::RandomFile::error
Error error(char *err)
Post an extended string error message.
Definition: file.h:447
ost::File::Mapping
Mapping
Definition: file.h:228
ost::MappedFile::release
void release(char *address, size_t len)
Release (unmap) a memory segment.
ost::File::completionDelayed
@ completionDelayed
Definition: file.h:235
ost::File::_fcb::address
char * address
Definition: file.h:155
ost::File::_fcb::len
ccxx_size_t len
Definition: file.h:156
ost::File::completionImmediate
@ completionImmediate
Definition: file.h:234
ost::File::_fcb
Definition: file.h:153
ost::File::errWriteIncomplete
@ errWriteIncomplete
Definition: file.h:132
thread.h
Synchronization and threading services.
ost::RandomFile
The purpose of this class is to define a base class for low level random file access that is portable...
Definition: file.h:397
ost::Dir::close
void close(void)
ost::String
This is a generic and portable string class.
Definition: string.h:81
ost::File::errNotOpened
@ errNotOpened
Definition: file.h:122
ost::RandomFile::setCompletion
Error setCompletion(Complete mode)
Used to set file completion modes.
ost::RandomFile::access
Access access
Definition: file.h:406
ost::File::errReadFailure
@ errReadFailure
Definition: file.h:130
PATH_MAX
#define PATH_MAX
Definition: file.h:110
ost::RandomFile::initialize
virtual Attr initialize(void)
This method is used to initialize a newly created file as indicated by the "initial" flag.
ost::Dir::operator++
const char * operator++(int)
Definition: file.h:292
ost::MappedFile
Create and map a disk file into memory.
Definition: file.h:748
ost::DSO::getObject
static DSO * getObject(const char *name)
Find a specific DSO object by filename.
ost::RandomFile::pathname
char * pathname
Definition: file.h:410
ost::RandomFile::isDevice
bool __EXPORT isDevice(const char *path)
ost::ThreadFile::fetch
Error fetch(char *address=NULL, ccxx_size_t length=0, off_t position=-1)
Fetch a portion of the file into physical memory.
ost::File::errWriteInterrupted
@ errWriteInterrupted
Definition: file.h:131