(self, offset: int, width: int)
| 324 | |
| 325 | # Read a single unsigned integer of the given width (1, 2, 4 or 8). |
| 326 | def _read_uint(self, offset: int, width: int) -> int: |
| 327 | assert self._cached_page is not None |
| 328 | if width == 1: |
| 329 | return self._read_bytes(offset, 1)[0] |
| 330 | elif width == 2: |
| 331 | return read_uint16_with_byteswap( |
| 332 | self._cached_page, offset, self.need_byteswap |
| 333 | ) |
| 334 | elif width == 4: |
| 335 | return read_uint32_with_byteswap( |
| 336 | self._cached_page, offset, self.need_byteswap |
| 337 | ) |
| 338 | elif width == 8: |
| 339 | return read_uint64_with_byteswap( |
| 340 | self._cached_page, offset, self.need_byteswap |
| 341 | ) |
| 342 | else: |
| 343 | self.close() |
| 344 | raise ValueError("invalid int width") |
| 345 | |
| 346 | def _read_bytes(self, offset: int, length: int): |
| 347 | assert self._cached_page is not None |
no test coverage detected