(
tar_path: &Path,
file_path: &Path,
compression: &Compression,
)
| 436 | } |
| 437 | |
| 438 | fn read_within( |
| 439 | tar_path: &Path, |
| 440 | file_path: &Path, |
| 441 | compression: &Compression, |
| 442 | ) -> anyhow::Result<Vec<u8>> { |
| 443 | let mut archive = tar::Archive::new(compression.open_reader(tar_path)?); |
| 444 | let Some(mut entry) = |
| 445 | archive.entries()?.flatten().find(|x| x.path().map_or(false, |path| path == file_path)) |
| 446 | else { |
| 447 | anyhow::bail!("failed to find {} in {}", file_path.display(), tar_path.display()); |
| 448 | }; |
| 449 | let mut buf = vec![]; |
| 450 | entry.read_to_end(&mut buf).with_context(|| { |
| 451 | format!("error reading: {} from {}", file_path.display(), tar_path.display()) |
| 452 | })?; |
| 453 | Ok(buf) |
| 454 | } |
no test coverage detected