]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Support 'whence' parameter to seek().
authorGuido van Rossum <guido@python.org>
Wed, 25 Mar 1998 16:25:26 +0000 (16:25 +0000)
committerGuido van Rossum <guido@python.org>
Wed, 25 Mar 1998 16:25:26 +0000 (16:25 +0000)
Lib/multifile.py

index 71e0dd0d46843364a4d0e793f107a2627b37a5b4..247b01079de5031ab36ef4e04ab577611ede396e 100644 (file)
@@ -44,8 +44,17 @@ class MultiFile:
                        return self.lastpos
                return self.fp.tell() - self.start
        #
-       def seek(self, pos):
-               if not 0 <= pos <= self.tell() or \
+       def seek(self, pos, whence=0):
+                here = self.tell()
+                if whence:
+                        if whence == 1:
+                                pos = pos + here
+                        elif whence == 2:
+                                if self.level > 0:
+                                        pos = pos + self.lastpos
+                                else:
+                                        raise Error, "can't use whence=2 yet"
+               if not 0 <= pos <= here or \
                                self.level > 0 and pos > self.lastpos:
                        raise Error, 'bad MultiFile.seek() call'
                self.fp.seek(pos + self.start)