(&self)
| 393 | } |
| 394 | |
| 395 | pub fn read(&self) -> anyhow::Result<Vec<u8>> { |
| 396 | match &self.kind { |
| 397 | PathKind::Path => { |
| 398 | let mut out = vec![]; |
| 399 | self.compression |
| 400 | .open_reader(&self.path) |
| 401 | .with_context(|| format!("failed to read: {}", self.path.display()))? |
| 402 | .read_to_end(&mut out)?; |
| 403 | Ok(out) |
| 404 | } |
| 405 | PathKind::Tar { subpath } => { |
| 406 | let file_path = subpath.as_deref().ok_or_else(|| { |
| 407 | anyhow::format_err!( |
| 408 | "expected subpath for .tar archive: {}", |
| 409 | self.path.display() |
| 410 | ) |
| 411 | })?; |
| 412 | read_within(&self.path, file_path, &self.compression) |
| 413 | } |
| 414 | } |
| 415 | } |
| 416 | |
| 417 | pub fn read_child(&self, file: &Path) -> anyhow::Result<Vec<u8>> { |
| 418 | match &self.kind { |
no test coverage detected