summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorFabian Freyer <mail@fabianfreyer.de>2022-11-28 19:19:26 +0100
committerKyle Martin <krm504@nyu.edu>2023-02-08 15:07:26 -0500
commit95129706bcbaaf9c651b0226cd68561d2dd58387 (patch)
tree4a60722f529b895b8f6079d0e3dca76ec326c498 /python
parent939f4f79a0343f707ac68f18ba6b0dd319fb4f80 (diff)
Bring BinaryReader.seek more in line with File
Adds a `whence` parameter to BinaryReader.seek which behaves similarly to FileObjects seek method, but defaults to 0, keeping backwards compatibility.
Diffstat (limited to 'python')
-rw-r--r--python/binaryview.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/python/binaryview.py b/python/binaryview.py
index eab2373a..c33d82c4 100644
--- a/python/binaryview.py
+++ b/python/binaryview.py
@@ -8460,11 +8460,12 @@ class BinaryReader:
return None
return struct.unpack(">Q", result)[0]
- def seek(self, offset: int) -> None:
+ def seek(self, offset: int, whence: int = 0) -> None:
"""
``seek`` update internal offset to ``offset``.
:param int offset: offset to set the internal offset to
+ :param int whence: optional, defaults to 0 for absolute file positioning, or 1 for relative to current location
:rtype: None
:Example:
@@ -8475,6 +8476,9 @@ class BinaryReader:
'0x100000000L'
>>>
"""
+ if whence:
+ self.seek_relative(offset)
+ return
core.BNSeekBinaryReader(self._handle, offset)
def seek_relative(self, offset: int) -> None: