Skip to content

Commit

Permalink
Add find to reader
Browse files Browse the repository at this point in the history
  • Loading branch information
bbqsrc committed Feb 5, 2024
1 parent 8085605 commit 4f9de76
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions box-format/src/file/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,16 @@ impl BoxFileReader {
.decompress_write(io::Cursor::new(mmap), dest)
}

#[inline(always)]
pub fn find(&self, path: &BoxPath) -> Result<&Record, ExtractError> {
let record = self
.meta
.inode(path)
.and_then(|x| self.meta.record(x))
.ok_or_else(|| ExtractError::NotFoundInArchive(path.to_path_buf()))?;
Ok(record)
}

#[inline(always)]
pub fn extract<P: AsRef<Path>>(
&self,
Expand Down

0 comments on commit 4f9de76

Please sign in to comment.