Crate librarium

Crate librarium 

Source
Expand description

Reader and Writer library for cpio archives

§Read

let mut file = File::open("archive.cpio").unwrap();
let mut archive = ArchiveReader::<NewcHeader>::from_reader_with_offset(&mut file, 0).unwrap();

// extract bytes from all in archive
for object in &archive.objects.inner {
    let mut out = OpenOptions::new()
        .write(true)
        .create(true)
        .open(object.header.as_header().name)
        .unwrap();
    archive.reader.extract_data(object, &mut out).unwrap();
}

§Write

let file = File::create("archive.cpio").unwrap();
let mut writer = ArchiveWriter::<NewcHeader>::new(Box::new(file));

// A
let a_data = "a\n".as_bytes();
let a_header = Header { name: "a".to_string(), ..Header::default()};
writer.push_file(Cursor::new(a_data), a_header).unwrap();

// write to archive
writer.write().unwrap();

§Features

  • std (enabled by default) — Enable std support
  • alloc (enabled by default) — Enable alloc support

Re-exports§

pub use cpio_header::CpioHeader;
pub use error::CpioError;
pub use read_seek::ReadSeek;
pub use newc::NewcHeader;
pub use odc::OdcHeader;

Modules§

cpio_header
error
newc
odc
read_seek

Structs§

ArchiveReader
Read cpio Archive and extract data
ArchiveWriter
Write cpio Archive and add data
Header
Common representation of cpio Header
Object
Object in cpio archive
Objects
All objects in archive

Enums§

Data
Reader and Writer of data

Traits§

CpioReader
Extract data from cpio Archive
WriteSeek
Write + Seek