pub struct ArchiveWriter<W: Write> { /* private fields */ }
compress
only.Expand description
Writes a 7z archive file.
Implementations§
Source§impl ArchiveWriter<File>
impl ArchiveWriter<File>
Source§impl<W: Write + Seek> ArchiveWriter<W>
impl<W: Write + Seek> ArchiveWriter<W>
Sourcepub fn auto_finish(self) -> AutoFinisher<Self>
pub fn auto_finish(self) -> AutoFinisher<Self>
Returns a wrapper around self
that will finish the stream on drop.
Sourcepub fn set_content_methods(
&mut self,
content_methods: Vec<EncoderConfiguration>,
) -> &mut Self
pub fn set_content_methods( &mut self, content_methods: Vec<EncoderConfiguration>, ) -> &mut Self
Sets the default compression methods to use for entry data. Default is LZMA2.
Sourcepub fn set_encrypt_header(&mut self, enabled: bool)
pub fn set_encrypt_header(&mut self, enabled: bool)
Whether to enable the encryption of the -header. Default is true
.
Sourcepub fn push_archive_entry<R: Read>(
&mut self,
entry: ArchiveEntry,
reader: Option<R>,
) -> Result<&ArchiveEntry, Error>
pub fn push_archive_entry<R: Read>( &mut self, entry: ArchiveEntry, reader: Option<R>, ) -> Result<&ArchiveEntry, Error>
Non-solid compression - Adds an archive entry
with data from reader
.
§Example
use std::{fs::File, path::Path};
use sevenz_rust2::*;
let mut sz = ArchiveWriter::create("path/to/dest.7z").expect("create writer ok");
let src = Path::new("path/to/source.txt");
let name = "source.txt".to_string();
let entry = sz
.push_archive_entry(
ArchiveEntry::from_path(&src, name),
Some(File::open(src).unwrap()),
)
.expect("ok");
let compressed_size = entry.compressed_size;
sz.finish().expect("done");
Sourcepub fn push_archive_entries<R: Read>(
&mut self,
entries: Vec<ArchiveEntry>,
reader: Vec<SourceReader<R>>,
) -> Result<&mut Self, Error>
pub fn push_archive_entries<R: Read>( &mut self, entries: Vec<ArchiveEntry>, reader: Vec<SourceReader<R>>, ) -> Result<&mut Self, Error>
Solid compression - packs entries
into one pack.
§Panics
- If
entries
’s length not equals toreader.reader_len()
Source§impl<W: Write + Seek> ArchiveWriter<W>
impl<W: Write + Seek> ArchiveWriter<W>
Sourcepub fn push_source_path(
&mut self,
path: impl AsRef<Path>,
filter: impl Fn(&Path) -> bool,
) -> Result<&mut Self, Error>
Available on crate feature util
and non-WebAssembly only.
pub fn push_source_path( &mut self, path: impl AsRef<Path>, filter: impl Fn(&Path) -> bool, ) -> Result<&mut Self, Error>
util
and non-WebAssembly only.Adds a source path to the compression builder with a filter function using solid compression.
The filter function allows selective inclusion of files based on their paths. Files are compressed using solid compression for better compression ratios.
§Arguments
path
- Path to add to the compressionfilter
- Function that returnstrue
for paths that should be included
Sourcepub fn push_source_path_non_solid(
&mut self,
path: impl AsRef<Path>,
filter: impl Fn(&Path) -> bool,
) -> Result<&mut Self, Error>
Available on crate feature util
and non-WebAssembly only.
pub fn push_source_path_non_solid( &mut self, path: impl AsRef<Path>, filter: impl Fn(&Path) -> bool, ) -> Result<&mut Self, Error>
util
and non-WebAssembly only.Adds a source path to the compression builder with a filter function using non-solid compression.
Non-solid compression allows individual file extraction without decompressing the entire archive, but typically results in larger archive sizes compared to solid compression.
§Arguments
path
- Path to add to the compressionfilter
- Function that returnstrue
for paths that should be included