Expand description
Reader and Writer library for cpio archives
§Supported Formats
| Format | Magic | Read | Write |
|---|---|---|---|
| odc (Old ASCII) | 070707 | Yes | Yes |
| newc (New ASCII / SVR4) | 070701 | Yes | Yes |
| newc-crc (New CRC) | 070702 | Yes | Yes |
§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) — Enablestdsupportalloc(enabled by default) — Enableallocsupport
Re-exports§
pub use cpio_header::CpioHeader;pub use error::CpioError;pub use read_seek::ReadSeek;pub use newc::NewcCrcHeader;pub use newc::NewcHeader;pub use odc::OdcHeader;
Modules§
- cpio_
header - Trait for common cpio header operations.
- error
- Error types returned by this library.
- newc
- New ASCII (SVR4) cpio header formats (
070701and070702). - odc
- Old ASCII (odc) cpio header format (
070707). - read_
seek - Composable
Read + Seektrait and helpers.
Structs§
- Archive
Reader - Read cpio Archive and extract data
- Archive
Writer - Write cpio Archive and add data
- Header
- Format-independent representation of a cpio header.
- Object
- Single entry (header + data) in a cpio archive.
- Objects
- All objects in archive
Enums§
- Data
- Reader and Writer of data
Traits§
- Cpio
Reader - Extract data from cpio Archive
- Write
Seek Write+Seek