|
|
@ -24,6 +24,7 @@ pub struct BDFWriter {
|
|
|
|
data_entries: Vec<DataEntry>,
|
|
|
|
data_entries: Vec<DataEntry>,
|
|
|
|
head_written: bool,
|
|
|
|
head_written: bool,
|
|
|
|
compressed: bool,
|
|
|
|
compressed: bool,
|
|
|
|
|
|
|
|
compression_level: u32,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
impl BDFWriter {
|
|
|
|
impl BDFWriter {
|
|
|
@ -36,6 +37,7 @@ impl BDFWriter {
|
|
|
|
writer,
|
|
|
|
writer,
|
|
|
|
head_written: false,
|
|
|
|
head_written: false,
|
|
|
|
compressed: compress,
|
|
|
|
compressed: compress,
|
|
|
|
|
|
|
|
compression_level: 1,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -81,7 +83,7 @@ impl BDFWriter {
|
|
|
|
let mut data_chunk =
|
|
|
|
let mut data_chunk =
|
|
|
|
GenericChunk::from_data_entries(&self.data_entries, &self.lookup_table);
|
|
|
|
GenericChunk::from_data_entries(&self.data_entries, &self.lookup_table);
|
|
|
|
if self.compressed {
|
|
|
|
if self.compressed {
|
|
|
|
data_chunk.compress()?;
|
|
|
|
data_chunk.compress(self.compression_level)?;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
let data = data_chunk.serialize();
|
|
|
|
let data = data_chunk.serialize();
|
|
|
|
self.writer.write(data.as_slice())?;
|
|
|
|
self.writer.write(data.as_slice())?;
|
|
|
@ -95,6 +97,11 @@ impl BDFWriter {
|
|
|
|
pub fn flush_writer(&mut self) -> Result<(), Error> {
|
|
|
|
pub fn flush_writer(&mut self) -> Result<(), Error> {
|
|
|
|
self.writer.flush()
|
|
|
|
self.writer.flush()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Sets the compression level for lzma compression
|
|
|
|
|
|
|
|
pub fn set_compression_level(&mut self, level: u32) {
|
|
|
|
|
|
|
|
self.compression_level = level;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
impl BDFReader {
|
|
|
|
impl BDFReader {
|
|
|
|