stream-read-until ( seps stream -- seq sep/f )
Factor handbook » Input and output » Streams » Stream protocol

Prev:stream-read-unsafe ( n buf stream -- count )
Next:stream-read-partial-unsafe ( n buf stream -- count )


Vocabulary
io

Inputs
sepsa string
streaman input stream


Outputs
seqa byte-array, a string, or f
sep/fa character or f


Generic word contract
Reads elements from the stream, until the first occurrence of a separator character, or stream exhaustion. In the former case, the separator is pushed on the stack, and is not part of the output string. In the latter case, the entire stream contents are output, along with f.

Notes
Most code only works on one stream at a time and should instead use read-until; see Default input and output streams.

Errors
Throws an error if the I/O operation fails.

Definition

GENERIC: stream-read-until ( seps stream -- seq sep/f )


Methods







M:: counting-stream stream-read-until
( seps stream -- seq sep/f )
seps stream stream>> stream-read-until :> ( seq sep ) sep
[ stream [ seq length + ] change-in-count drop ] when
seq sep ;