stream-seekable? ( stream -- ? ) (original) (raw)

stream-seekable? ( stream -- ? )
Factor handbook » Input and output » Streams » Stream protocol

Prev: stream-nl ( stream -- )
Next: stream-tell ( stream -- n )

Vocabulary
io

Inputs

stream a stream

Outputs

? a boolean

Word description
Returns true if stream is a seekable stream.

Notes
Stream seeking is not supported on streams that do not have a known length, e.g. TCP/IP streams.

See also
stream-seek, stream-tell, stream-length

Definition

IN: io

GENERIC: stream-seekable? ( stream -- ? )

Methods

USING: accessors io io.ports ;

M: buffered-port stream-seekable? handle>> can-seek-handle? ;

USING: io io.streams.byte-array kernel ;

M: byte-reader stream-seekable? drop t ; inline

USING: io kernel ;

M: input-stream stream-seekable? drop f ; inline

USING: accessors io io.streams.limited ;

M: limited-stream stream-seekable? stream>> stream-seekable?
; inline

USING: io kernel ;

M: output-stream stream-seekable? drop f ; inline

USING: io io.streams.string kernel ;

M: string-reader stream-seekable? drop t ; inline

USING: accessors io io.streams.throwing ;

M: throws-on-eof-stream stream-seekable?
stream>> stream-seekable? ;