#cpio #archive #gnu #format #reader-writer #crc #character

kpea

CPIO archive reader/writer library. Supports New ASCII and Old character formats. Fuzz-tested against GNU cpio.

7 releases

0.2.4 Dec 9, 2024
0.2.3 Nov 30, 2024
0.1.1 Nov 17, 2024

#542 in Encoding

Download history 62/week @ 2024-11-11 294/week @ 2024-11-18 296/week @ 2024-11-25 39/week @ 2024-12-02 168/week @ 2024-12-09

859 downloads per month

MIT license

72KB
2K SLoC

kpea

Crates.io Version Docs dependency status

CPIO archive reader/writer library. Supports New ASCII, New CRC, Old character, and New binary formats.

Introduction

kpea is a library that offers Archive and Builder types that unpack/pack CPIO archives. The library is fuzz-tested against GNU cpio.

Adding as a dependency

To import kpea as cpio use the following syntax.

[dependencies]
cpio = { package = "kpea", version = "0.1.0" }

Example

use kpea as cpio; // not needed if you added dependency as `cpio`
use std::fs::File;
use std::io::Error;

fn create_archive() -> Result<(), Error> {
    let file = File::create("archive.cpio")?;
    let mut builder = cpio::Builder::new(file);
    builder.append_path("/etc/passwd", "passwd")?;
    builder.append_path("/etc/group", "group")?;
    builder.finish()?;
    Ok(())
}

fn open_archive() -> Result<(), Error> {
    let file = File::open("archive.cpio")?;
    let mut archive = cpio::Archive::new(file);
    while let Some(mut entry) = archive.read_entry()? {
        println!("{:?}", entry.path);
    }
    Ok(())
}

Dependencies