5 releases (stable)
1.2.2 | Apr 23, 2022 |
---|---|
1.0.0 | Apr 10, 2022 |
0.1.1 | Apr 1, 2022 |
#482 in Compression
49 downloads per month
45KB
1K
SLoC
Zip archive
zip_archive
is a library that archive a directory with a specific compression format.
Supports multi-threading.
Requirements for 7z format
To use 7z archiving format, you need to install 7z or get the executable depending on the operating system.
Windows 10
- Install 7-Zip.
- Find 7z.exe file in installed 7z folder and add it to path. Or place 7z.exe in project root folder.
macOS
- Download 7-Zip console version executable for macOS.
- Place 7zz executable to home directory.
Examples
For more information and examples, see document page.
lib.rs
:
Zip archive
zip_archive
is a library that archive a directory with a specific compression format.
Supports multi-threading.
Supported Formats
Formats | description |
---|---|
xz | Using [xz2] crate. |
7z | See Requirements section. |
[zip] | Using [zip] crate. |
Examples
- Compress root directory with 4 threads.
use std::path::PathBuf;
use zip_archive::Archiver;
let origin = PathBuf::from("./origin");
let dest = PathBuf::from("./dest");
let thread_count = 4;
let mut archiver = Archiver::new();
archiver.push(origin);
archiver.set_destination(dest);
archiver.set_thread_count(thread_count);
match archiver.archive(){
Ok(_) => (),
Err(e) => println!("Cannot archive the directory! {}", e),
};
- Compress each directory using the container's iterator.
use std::path::PathBuf;
use zip_archive::Archiver;
let origin = PathBuf::from("./origin");
let dest = PathBuf::from("./dest");
let mut archiver = Archiver::new();
archiver.push_from_iter(vec!["./origin/dir1", "./origin/dir2", "./origin/dir3"].into_iter());
archiver.set_destination(dest);
match archiver.archive(){
Ok(_) => (),
Err(e) => println!("Cannot archive the directory! {}", e),
};
- Compress directory with .xz format.
use std::path::PathBuf;
use zip_archive::Format;
use zip_archive::{Archiver, get_dir_list_with_depth};
let origin = PathBuf::from("./origin"); // Change to the wanted directory.
let dest = PathBuf::from("./dest");
let mut archiver = Archiver::new();
archiver.push(origin);
archiver.set_destination(dest);
archiver.set_format(Format::Xz); // == `archiver.set_format_str("xz");`
match archiver.archive(){
Ok(_) => (),
Err(e) => println!("Cannot archive the directory! {}", e),
};
Requirements for 7z format
To use 7z archiving format, you need to install 7z or get the executable depending on the operating system.
Windows 10
- Install 7-Zip.
- Find 7z.exe file in installed program folder and add it to path. Or place it in project root folder.
macOS
- Download 7-Zip console version executable for macOS.
- Place 7zz executable to home directory.
Dependencies
~8–17MB
~241K SLoC