Joedb
9.1.4
The Journal-Only Embedded Database
Loading...
Searching...
No Matches
src
joedb
journal
File_Slice.h
Go to the documentation of this file.
1
#ifndef joedb_File_Slice_declared
2
#define joedb_File_Slice_declared
3
4
#include "
joedb/journal/Readonly_Memory_File.h
"
5
#include "
joedb/journal/Posix_File.h
"
6
7
#include <sys/mman.h>
8
9
namespace
joedb
10
{
11
/// @ingroup journal
12
class
File_Slice
:
public
Readonly_Memory_File
13
{
14
private
:
15
const
size_t
mapped_size;
16
17
public
:
18
File_Slice
(
int
fd,
size_t
offset,
size_t
size):
19
Readonly_Memory_File
20
(
21
(
char
*)
mmap
22
(
23
nullptr
,
24
offset + size,
25
PROT_READ
,
26
MAP_PRIVATE
,
27
fd,
28
0
29
) + offset,
30
size
31
),
32
mapped_size(offset + size)
33
{
34
if
(
data
- offset ==
MAP_FAILED
)
35
Posix_File::throw_last_error
(
"mapping"
,
"file"
);
36
}
37
38
File_Slice
(
const
File_Slice
&) =
delete
;
39
File_Slice
&
operator=
(
const
File_Slice
&) =
delete
;
40
41
~File_Slice
()
42
{
43
munmap
(
const_cast<
void
*
>
(
static_cast<
const
void
*
>
(
data
)), mapped_size);
44
}
45
};
46
}
47
48
#endif
Posix_File.h
Readonly_Memory_File.h
joedb::Buffered_File::read
T read()
Definition
Buffered_File.h:156
joedb::File_Slice
Definition
File_Slice.h:13
joedb::File_Slice::~File_Slice
~File_Slice()
Definition
File_Slice.h:41
joedb::File_Slice::operator=
File_Slice & operator=(const File_Slice &)=delete
joedb::File_Slice::File_Slice
File_Slice(int fd, size_t offset, size_t size)
Definition
File_Slice.h:18
joedb::File_Slice::File_Slice
File_Slice(const File_Slice &)=delete
joedb::Posix_FD::throw_last_error
static void throw_last_error(const char *action, const char *file_name)
Definition
Posix_File.cpp:35
joedb::Readonly_Memory_File
Definition
Readonly_Memory_File.h:13
joedb::Readonly_Memory_File::data
const char * data
Definition
Readonly_Memory_File.h:15
joedb
Definition
Blob.h:7
Generated by
1.9.8