#include <flatfile.h>
FlatFileSeq represents a sequence of numbered files storing raw data. This class facilitates access to and efficient management of these files.
◆ FlatFileSeq()
FlatFileSeq::FlatFileSeq |
( |
fs::path |
dir, |
|
|
const char * |
prefix, |
|
|
size_t |
chunk_size |
|
) |
| |
Constructor
- Parameters
-
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. |
◆ Allocate()
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.
- Parameters
-
[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. |
- Returns
- The number of bytes successfully allocated.
◆ FileName()
fs::path FlatFileSeq::FileName |
( |
const FlatFilePos & |
pos | ) |
const |
Get the name of the file at the given position.
◆ Flush()
bool FlatFileSeq::Flush |
( |
const FlatFilePos & |
pos, |
|
|
bool |
finalize = false |
|
) |
| |
Commit a file to disk, and optionally truncate off extra pre-allocated bytes if final.
- Parameters
-
[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. |
- Returns
- true on success, false on failure.
◆ Open()
FILE * FlatFileSeq::Open |
( |
const FlatFilePos & |
pos, |
|
|
bool |
read_only = false |
|
) |
| |
Open a handle to the file at the given position.
◆ m_chunk_size
const size_t FlatFileSeq::m_chunk_size |
|
private |
◆ m_dir
const fs::path FlatFileSeq::m_dir |
|
private |
◆ m_prefix
const char* const FlatFileSeq::m_prefix |
|
private |
The documentation for this class was generated from the following files: