fn find_tar_entry<R: Read>(archive: &mut TarArchive<R>, path: impl AsRef<Path>) -> Result<Option<impl Read + '_>> {
    for entry in archive.entries().context("failed getting archive entries")? {
        let entry = entry.context("error while getting archive entry")?;
        let name = entry.path().context("invalid entry path")?;

        let mut name = name.components();
        name.next();

        if name.as_path() == path.as_ref() {
            return Ok(Some(entry));
        }
    }

    Ok(None)
}
/// Find an entry in a TAR archive by name and open it for reading. The first part of the path is
/// dropped as that's usually the folder name it was created from.
Find an entry in a TAR archive by name and open it for reading. The first part of the path is
dropped as that's usually the folder name it was created from.
Find an entry in a TAR archive by name and open it for reading . The first part of the path is dropped as that ' s usually the folder name it was created from .
fn find_tar_entry<R: Read>(archive: &mut TarArchive<R>, path: impl AsRef<Path>) -> Result<Option<impl Read + '_>> {
    for entry in archive.entries().context("failed getting archive entries")? {
        let entry = entry.context("error while getting archive entry")?;
        let name = entry.path().context("invalid entry path")?;
        let mut name = name.components();
        name.next();
        if name.as_path() == path.as_ref() {
            return Ok(Some(entry));
        }
    }
    Ok(None)
}
fn find_tar_entry < R : Read > ( archive : & mut TarArchive < R > , path : impl AsRef < Path > ) -> Result < Option < impl Read + ' _ > > { for entry in archive . entries ( ) . context ( " " ) ? { let entry = entry . context ( " " ) ? ; let name = entry . path ( ) . context ( " " ) ? ; let mut name = name . components ( ) ; name . next ( ) ; if name . as_path ( ) == path . as_ref ( ) { return Ok ( Some ( entry ) ) ; } } Ok ( None ) }
Find an entry in a TAR archive by name and open it for reading.
Find an entry in a TAR archive by name and open it for reading .
archive
&mut TarArchive<R>
path
impl AsRef<Path>