-
Notifications
You must be signed in to change notification settings - Fork 26
Description
Currently TranscodingStreams has default methods for seekstart
seekend
and position
. position
implementation is based on the bytes read from the io. However, when seekstart
or seekend
is called, it will lead to invalid position. For example:
# Create a gzip file
using CodecZlib
s = GzipCompressorStream(open("/tmp/test.txt.gz", "w"))
write(s, "abbccc"); close(s)
# Reading stream
s = GzipDecompressorStream(open("/tmp/test.txt.gz"))
read(s, Char); position(s) ## position is 1, correct!
seekstart(s); position(s) ## position changes to 6, it should be 0
read(s, Char); position(s) ## position changes to 7, it should be 1
seekend(s); position(s) ## position changes to 12, it should be 6
I think when seekstart
is called, we probably need to reset the Stats of the stream. For seekend
, I think it might be hard/impossible to get the right position after decompression, however at least an warning should be given. seek
is not provided by default, however if a Codec implements only seek
but not position
, it might leads invalid position as well.
What's your thoughts on this issue? Maybe it is possible to just issue an warning when calling position
after called seek/seekstart/seekend? Then a Codec might implements its specialized methods for position
(e.g. for Noop
).