MCPcopy Create free account
hub / github.com/MultiFuzz/MultiFuzz / read_within

Function read_within

hail-fuzz/src/debugging/replay.rs:438–454  ·  view source on GitHub ↗
(
    tar_path: &Path,
    file_path: &Path,
    compression: &Compression,
)

Source from the content-addressed store, hash-verified

436}
437
438fn 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}

Callers 2

readMethod · 0.85
read_childMethod · 0.85

Calls 1

open_readerMethod · 0.80

Tested by

no test coverage detected