Seek to the specified position.
(&mut self, pos: SeekFrom)
| 101 | impl Seek for BinaryReader { |
| 102 | /// Seek to the specified position. |
| 103 | fn seek(&mut self, pos: SeekFrom) -> std::io::Result<u64> { |
| 104 | match pos { |
| 105 | SeekFrom::Current(offset) => self.seek_to_relative_offset(offset), |
| 106 | SeekFrom::Start(offset) => self.seek_to_offset(offset), |
| 107 | SeekFrom::End(end_offset) => { |
| 108 | // We do NOT need to add the image base here as |
| 109 | // the reader (unlike the writer) can set the virtual base. |
| 110 | let offset = |
| 111 | self.view |
| 112 | .len() |
| 113 | .checked_add_signed(end_offset) |
| 114 | .ok_or(std::io::Error::new( |
| 115 | ErrorKind::Other, |
| 116 | "Seeking from end overflowed", |
| 117 | ))?; |
| 118 | self.seek_to_offset(offset); |
| 119 | } |
| 120 | }; |
| 121 | |
| 122 | Ok(self.offset()) |
| 123 | } |
| 124 | } |
| 125 | |
| 126 | impl Read for BinaryReader { |