6 releases

0.4.0 Feb 25, 2023
0.3.5 Feb 27, 2023
0.2.3 Feb 19, 2023
0.2.1 Jan 26, 2023
0.1.0 Jan 22, 2023

#227 in Compression

40 downloads per month
Used in comic-repack

MIT license

30KB
615 lines

archive-reader

ArchiveReader is a library that wraps partial read functions from libarchive. It provides rustic interface over listing file names and reading given files within archives.

[dependencies]
archive-reader = "0.3"

Example

use archive_reader::Archive;
use archive_reader::error::Result;

fn main() -> Result<()> {
    let mut archive = Archive::open("some_archive.zip");
    let file_names = archive
                        .block_size(1024 * 1024)
                        .list_file_names()?
                        .collect::<Result<Vec<_>>>()?;
    let mut content = vec![];
    let _ = archive.read_file(&file_names[0], &mut content)?;
    println!("content={:?}", content);
    Ok(())
}

Features

  • lending_iter - Enables LendingIterator implementation, which avoids heap allocations for read_file_by_block functions.

Getting Started

This section talks about compiling this project

Prerequisites:

  • Rust 1.66.0 (May be compatible with lower versions, but I used 1.66.0)
  • Cargo
  • Git
  • libc
  • libarchive >= 3.2.0
    • Check it with command pkg-config --libs --cflags libarchive 'libarchive >= 3.2.0'

Compile

cd SOME_DIR
git clone git@github.com:YaxinCheng/archive-reader.git
cd archive-reader
cargo build --release

Dependencies

~0.3–0.9MB
~21K SLoC