pxar: Refactor SequentialDecoder to store the callback function within the struct

Reduces the number of arguments for the function calls within the decoder.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
This commit is contained in:
Christian Ebner
2019-07-04 14:03:20 +02:00
committed by Dietmar Maurer
parent b46c3fad03
commit 7dcbe051e9
5 changed files with 34 additions and 44 deletions

View File

@ -31,14 +31,14 @@ impl PxarDecodeWriter {
let child = thread::spawn(move|| {
let mut reader = unsafe { std::fs::File::from_raw_fd(rx) };
let mut decoder = pxar::SequentialDecoder::new(&mut reader, pxar::CA_FORMAT_DEFAULT);
if let Err(err) = decoder.restore(&base, & |path| {
let mut decoder = pxar::SequentialDecoder::new(&mut reader, pxar::CA_FORMAT_DEFAULT, |path| {
if verbose {
println!("{:?}", path);
}
Ok(())
}) {
});
if let Err(err) = decoder.restore(&base) {
eprintln!("pxar decode failed - {}", err);
}
});