Add a delegating read_exact() on Reader so we can use the same Reader for more things

This commit is contained in:
Christopher Cole 2022-10-07 15:26:07 -07:00
parent 81112fcd51
commit a7ce73ee98
No known key found for this signature in database
GPG Key ID: 0AC856975983E9DB
2 changed files with 6 additions and 2 deletions

View File

@ -105,9 +105,9 @@ impl File {
continue;
}
io_file.seek(io::SeekFrom::Start(section.shdr.sh_offset))?;
reader.seek(io::SeekFrom::Start(section.shdr.sh_offset))?;
section.data.resize(section.shdr.sh_size as usize, 0u8);
io_file.read_exact(&mut section.data)?;
reader.read_exact(&mut section.data)?;
}
// Parse the section names from the section header string table

View File

@ -35,6 +35,10 @@ impl<'data, D: Read + Seek> Reader<'data, D> {
Reader{delegate: delegate, endian: endian}
}
pub fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), std::io::Error> {
self.delegate.read_exact(buf)
}
pub fn seek(&mut self, pos: std::io::SeekFrom) -> Result<u64, std::io::Error> {
self.delegate.seek(pos)
}