src/pxar/decoder.rs: implement seekable decoder

This commit is contained in:
Dietmar Maurer
2019-03-15 09:36:05 +01:00
parent 0e21b87be3
commit 46cfe7ab7e
4 changed files with 297 additions and 658 deletions

View File

@ -36,7 +36,11 @@ impl <'a, R: Read> SequentialDecoder<'a, R> {
Self { reader, skip_buffer }
}
fn read_item<T: Endian>(&mut self) -> Result<T, Error> {
pub (crate) fn get_reader_mut(&mut self) -> & mut R {
self.reader
}
pub (crate) fn read_item<T: Endian>(&mut self) -> Result<T, Error> {
let mut result: T = unsafe { std::mem::uninitialized() };
@ -71,7 +75,7 @@ impl <'a, R: Read> SequentialDecoder<'a, R> {
Ok(PathBuf::from(std::ffi::OsString::from_vec(buffer)))
}
fn read_filename(&mut self, size: u64) -> Result<OsString, Error> {
pub (crate) fn read_filename(&mut self, size: u64) -> Result<OsString, Error> {
if size < (HEADER_SIZE + 2) {
bail!("dectected short filename");
}