00001
00002
00003 #ifndef BASE_MEMORYMAPPEDFILE_H
00004 #define BASE_MEMORYMAPPEDFILE_H
00005
00006 #include "File.h"
00007
00008 namespace base {
00010
00014 class PPBASE_EXPORT MemoryMappedFile {
00015 public:
00017 MemoryMappedFile();
00018
00020
00025 MemoryMappedFile(const File &file, bool writeable = false, bool privt = false);
00026
00028 ~MemoryMappedFile();
00029
00031
00034 unsigned getLength() const;
00035
00037
00040 char *getStart() const;
00041
00043
00049 char *map(const File &file, bool writeable = false, bool privt = false);
00050
00052
00060 char *map(const File &file, u_longlong_t offset, unsigned length, bool writeable = false, bool privt = false);
00061
00063 void unmap();
00064
00065 private:
00066 #ifdef _WIN32
00067 HANDLE _handle;
00068 #else
00069 int _fd;
00070 #endif
00071 String _fname;
00072 unsigned _length;
00073 void *_start;
00074
00075 DISALLOW_COPY_CONSTRUCTOR_AND_ASSIGNMENT(MemoryMappedFile);
00076 };
00077 }
00078
00079 #endif