Commit 69c70a2f authored by Guido van Rossum's avatar Guido van Rossum

Support 'whence' parameter to seek().

parent 55730316
......@@ -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)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment