diff --git a/basis/io/streams/byte-array/byte-array.factor b/basis/io/streams/byte-array/byte-array.factor index b877e97cf1..16160cd42d 100644 --- a/basis/io/streams/byte-array/byte-array.factor +++ b/basis/io/streams/byte-array/byte-array.factor @@ -2,7 +2,7 @@ ! See http://factorcode.org/license.txt for BSD license. USING: byte-arrays byte-vectors kernel io.encodings io.streams.string sequences io namespaces io.encodings.private accessors sequences.private -io.streams.sequence destructors ; +io.streams.sequence destructors math combinators ; IN: io.streams.byte-array : ( encoding -- stream ) @@ -20,6 +20,14 @@ M: byte-reader stream-read1 sequence-read1 ; M: byte-reader stream-read-until sequence-read-until ; M: byte-reader dispose drop ; +M: byte-reader stream-seek ( n seek-type stream -- ) + swap { + { seek-absolute [ (>>i) ] } + { seek-relative [ [ + ] change-i drop ] } + { seek-end [ dup underlying>> length >>i [ + ] change-i drop ] } + [ bad-seek-type ] + } case ; + : ( byte-array encoding -- stream ) [ B{ } like 0 byte-reader boa ] dip ;