33 const int page_size = getpagesize();
84 int flags = MAP_FILE | MAP_SHARED;
94 std::string message =
"on file " + this->
full_name();
95 throw OksSystem::OksSystemCallIssue(
ERS_HERE, errno,
"mmap", message.c_str() );
110 std::string message =
"on file " + this->
full_name();
111 throw OksSystem::OksSystemCallIssue(
ERS_HERE, errno,
"munmap", message.c_str() );
124 const int page_size = ::getpagesize();
126 void *buffer= calloc(1,page_size);
127 for(
int i=0;i<page_num;i++) {
128 fd.write(buffer,page_size);
#define ERS_PRECONDITION(expression)
#define ERS_ASSERT(expression)
File descriptor / Socket wrapper.
static int flags(bool read_mode, bool write_mode)
File(const std::string &name)
const std::string & full_name() const
full name for file */
void unmap_mem()
unmaps the file into memory
void * m_map_address
the address of the map in memory
void zero() const
builds a zeroed file with correct length
size_t m_map_offset
offset in the file of the map
size_t m_map_size
the size of the map
MapFile(const std::string &file, size_t size, size_t offset, bool read_mode, bool write_mode, mode_t permissions=0666)
bool is_mapped() const
is the file mopped im memory
bool m_map_write
is the map writable
void unmap()
unmaps the file
Descriptor * m_map_descriptor
internal file descriptor
bool m_is_mapped
is the file mapped in memory
bool is_loaded() const
is the map loaded in memory
OksSystem::Descriptor * fd() const
the file descriptor. This method returns a valid pointer only if called after map().
void open_fd()
opens the file descriptor for the map
void close_fd()
closes the file descriptor for the map
size_t memory_size() const
the size of the map
void map_mem()
maps the file into memory
bool m_map_read
is the map readable
void map()
maps the file in memory
mode_t m_map_permission
permissions associated with the file
void * address() const
the address of the memory mapped file