11 #ifndef __MEMORYMAPPEDFILE_H__
12 #define __MEMORYMAPPEDFILE_H__
21 #include <sys/types.h>
37 SG_UNSTABLE(
"CMemoryMappedFile::CMemoryMappedFile()",
72 open_flags=O_RDWR | O_CREAT;
73 mmap_prot=PROT_READ|PROT_WRITE;
74 mmap_flags=MAP_SHARED;
80 mmap_flags=MAP_PRIVATE;
85 fd = open(fname, open_flags, S_IRWXU | S_IRWXG | S_IRWXO);
92 if (lseek(
fd, fsize, SEEK_SET) != fsize || write(
fd, &byte, 1) != 1)
93 SG_ERROR(
"Error creating file of size %ld bytes\n", fsize);
97 if (fstat(
fd, &sb) == -1)
98 SG_ERROR(
"Error determining file size\n");
165 for (uint64_t i=offs; i<
length; i++)
191 void write_line(
const char* line, uint64_t len, uint64_t& offs)
193 char* s = ((
char*)
address) + offs;
195 SG_ERROR(
"Writing beyond size of file\n");
197 for (uint64_t i=0; i<len; i++)
229 for (uint64_t i=0; i<
length; i++)
263 inline virtual const char*
get_name()
const {
return "MemoryMappedFile"; }