Struct bitcoin_block::FlatFileSeq
source · Expand description
| FlatFileSeq represents a sequence | of numbered files storing raw data. | This class facilitates access to and | efficient management of these files. |
Fields§
§dir: PathBuf§prefix: *const u8§chunk_size: usizeImplementations§
source§impl FlatFileSeq
impl FlatFileSeq
sourcepub fn new(
dir: PathBuf,
prefix: *const u8,
chunk_size: usize
) -> Result<Self, StdException>
pub fn new(
dir: PathBuf,
prefix: *const u8,
chunk_size: usize
) -> Result<Self, StdException>
| Constructor | | ———– | @param dir | | The base directory that all files live | in. | ––––– | @param prefix | | A short prefix given to all file names. | ––––– | @param chunk_size | | Disk space is pre-allocated in multiples | of this amount. |
sourcepub fn file_name(&self, pos: &FlatFilePos) -> PathBuf
pub fn file_name(&self, pos: &FlatFilePos) -> PathBuf
| Get the name of the file at the given position. |
sourcepub fn open(&mut self, pos: &FlatFilePos, read_only: Option<bool>) -> *mut FILE
pub fn open(&mut self, pos: &FlatFilePos, read_only: Option<bool>) -> *mut FILE
| Open a handle to the file at the given | position. |
sourcepub fn allocate(
&mut self,
pos: &FlatFilePos,
add_size: usize,
out_of_space: &mut bool
) -> usize
pub fn allocate(
&mut self,
pos: &FlatFilePos,
add_size: usize,
out_of_space: &mut bool
) -> usize
| 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. | | ———– | @param[in] pos | | The starting position that bytes will | be allocated after. | ––––– | @param[in] add_size | | The minimum number of bytes to be allocated. | ––––– | @param[out] out_of_space | | Whether the allocation failed due to | insufficient disk space. | | ———– | @return | | The number of bytes successfully allocated. |
sourcepub fn flush(
&mut self,
pos: &FlatFilePos,
finalize: Option<bool>
) -> Result<bool, String>
pub fn flush(
&mut self,
pos: &FlatFilePos,
finalize: Option<bool>
) -> Result<bool, String>
| Commit a file to disk, and optionally | truncate off extra pre-allocated bytes | if final. | | ———– | @param[in] pos | | The first unwritten position in the | file to be flushed. | ––––– | @param[in] finalize | | True if no more data will be written to | this file. | | ———– | @return | | true on success, false on failure. |