Bitcoin ABC 0.30.7
P2P Digital Currency
|
FlatFileSeq represents a sequence of numbered files storing raw data. More...
#include <flatfile.h>
Public Member Functions | |
FlatFileSeq (fs::path dir, const char *prefix, size_t chunk_size) | |
Constructor. More... | |
fs::path | FileName (const FlatFilePos &pos) const |
Get the name of the file at the given position. More... | |
FILE * | Open (const FlatFilePos &pos, bool read_only=false) |
Open a handle to the file at the given position. More... | |
size_t | Allocate (const FlatFilePos &pos, size_t add_size, bool &out_of_space) |
Allocate additional space in a file after the given starting position. More... | |
bool | Flush (const FlatFilePos &pos, bool finalize=false) |
Commit a file to disk, and optionally truncate off extra pre-allocated bytes if final. More... | |
Private Attributes | |
const fs::path | m_dir |
const char *const | m_prefix |
const size_t | m_chunk_size |
FlatFileSeq represents a sequence of numbered files storing raw data.
This class facilitates access to and efficient management of these files.
Definition at line 49 of file flatfile.h.
FlatFileSeq::FlatFileSeq | ( | fs::path | dir, |
const char * | prefix, | ||
size_t | chunk_size | ||
) |
Constructor.
dir | The base directory that all files live in. |
prefix | A short prefix given to all file names. |
chunk_size | Disk space is pre-allocated in multiples of this amount. |
Definition at line 13 of file flatfile.cpp.
size_t FlatFileSeq::Allocate | ( | const FlatFilePos & | pos, |
size_t | add_size, | ||
bool & | out_of_space | ||
) |
Allocate additional space in a file after the given starting position.
The amount allocated will be the minimum multiple of the sequence chunk size greater than add_size.
[in] | pos | The starting position that bytes will be allocated after. |
[in] | add_size | The minimum number of bytes to be allocated. |
[out] | out_of_space | Whether the allocation failed due to insufficient disk space. |
Definition at line 51 of file flatfile.cpp.
fs::path FlatFileSeq::FileName | ( | const FlatFilePos & | pos | ) | const |
Get the name of the file at the given position.
Definition at line 24 of file flatfile.cpp.
bool FlatFileSeq::Flush | ( | const FlatFilePos & | pos, |
bool | finalize = false |
||
) |
Commit a file to disk, and optionally truncate off extra pre-allocated bytes if final.
[in] | pos | The first unwritten position in the file to be flushed. |
[in] | finalize | True if no more data will be written to this file. |
Definition at line 80 of file flatfile.cpp.
FILE * FlatFileSeq::Open | ( | const FlatFilePos & | pos, |
bool | read_only = false |
||
) |
Open a handle to the file at the given position.
Definition at line 28 of file flatfile.cpp.
|
private |
Definition at line 53 of file flatfile.h.
|
private |
Definition at line 51 of file flatfile.h.
|
private |
Definition at line 52 of file flatfile.h.