Closed bonigarcia closed 8 months ago
The interface for cpio_reader
is... awkward. It's both an Iterator
and a Read
er for the current archive. So you can do something like this:
for package in packages.iter() {
if let Some(cpio_reader) = package.payload_reader()? {
while let Some(e) = cpio_reader.next() {
let e = entry?;
let name = e.name();
let mut contents = Vec::new();
cpio_reader.read_to_end(&mut contents)?;
// Write contents somewhere.
println!("---> {}", name);
}
}
}
That worked, many thanks for the quick reply, @roblabla! I updated my example just in case it is helpful for someone.
Hello. I need a pure Rust implementation to extract the content of a PKG file. As recommended in #90, the
apple-flat-package
crate in this repo should support this decoding.I've been trying the
apple-flat-package
, but so far, I only managed to list the Payload content (i.e., a cpio archive). My current solution is the following:Instead of simply listing the content, I need to extract the content of the Payload to a target path in my file system. I believe I'm close, but I don't know how to do it.
Can you please guide me? I really appreciate any help you can provide.