Skip to content

Commit

Permalink
cli: Fix unpack fast-path for non-zero image offsets (#58)
Browse files Browse the repository at this point in the history
  • Loading branch information
antangelo authored Nov 14, 2023
1 parent 1be8df3 commit 8aea79a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion xdvdfs-cli/src/cmd_read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ pub async fn cmd_unpack(img_path: &str, target_dir: &Option<String>) -> Result<(
.create(true)
.open(file_path)?;

dirent.node.dirent.seek_to(img.get_mut())?;
dirent.node.dirent.seek_to(&mut img)?;
let data = img.get_ref().get_ref().try_clone();
match data {
Ok(data) => {
Expand Down
14 changes: 14 additions & 0 deletions xdvdfs-core/src/blockdev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,20 @@ where
}
}

#[cfg(feature = "std")]
impl<T, E> std::io::Seek for OffsetWrapper<T, E>
where
T: BlockDeviceRead<E> + std::io::Seek,
{
fn seek(&mut self, pos: std::io::SeekFrom) -> std::io::Result<u64> {
use std::io::SeekFrom;
match pos {
SeekFrom::Start(pos) => self.inner.seek(SeekFrom::Start(self.offset + pos)),
pos => self.inner.seek(pos),
}
}
}

#[cfg(all(feature = "std", feature = "read"))]
#[maybe_async(?Send)]
impl<R> BlockDeviceRead<std::io::Error> for R
Expand Down

0 comments on commit 8aea79a

Please sign in to comment.