File tree Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -41,6 +41,19 @@ function TranscodingStream(codec::Noop, stream::IO;
41
41
return TranscodingStream (codec, stream, State (buffer, buffer))
42
42
end
43
43
44
+ """
45
+ position(stream::NoopStream)
46
+
47
+ Get the current poition of `stream`.
48
+
49
+ Note that this method may return a wrong position when
50
+ - some data have been inserted by `TranscodingStreams.unread`, or
51
+ - the position of the wrapped stream has been changed outside of this package.
52
+ """
53
+ function Base. position (stream:: NoopStream )
54
+ return position (stream. stream) - buffersize (stream. state. buffer1)
55
+ end
56
+
44
57
function Base. seek (stream:: NoopStream , pos:: Integer )
45
58
seek (stream. stream, pos)
46
59
initbuffer! (stream. state. buffer1)
Original file line number Diff line number Diff line change 80
80
@test take! (sink) == data
81
81
close (stream)
82
82
83
+ stream = TranscodingStream (Noop (), IOBuffer (b " foobarbaz" ))
84
+ @test position (stream) === 0
85
+ read (stream, UInt8)
86
+ @test position (stream) === 1
87
+ read (stream)
88
+ @test position (stream) === 9
89
+
83
90
data = collect (0x00 : 0x0f )
84
91
stream = TranscodingStream (Noop (), IOBuffer (data))
85
92
@test ! ismarked (stream)
You can’t perform that action at this time.
0 commit comments