Quirrel4.41.0

iostream.blob.eos

Method of blob, from module "iostream"

Returns non-null if the stream is at end-of-stream

examples/iostream/blob/eos-basic.nut
from "iostream" import blob

let cargo = blob(4)
cargo.readn('i')            // consumes all 4 bytes
println("cargo.eos() =", cargo.eos())
Output:
cargo.eos() = 1

Return value

See iostream.stream.eos for the generic contract.

Notes

For a blob this is tell() == len(). Both change often on a blob - len grows on a write past the end, tell moves on every read, write or seek - so eos reflects the current state of both, not a sticky flag.

Example

examples/iostream/blob/eos.nut
from "iostream" import blob

let b = blob(2)
println("b.eos() at start =", b.eos())        // cursor 0, len 2: not at the end
b.readn('b')
println("b.eos() after 1 readn('b') =", b.eos())        // cursor 1, len 2: still not there
b.readn('b')
println("b.eos() after 2 readn('b') =", b.eos())        // cursor 2, len 2: now at the end

b.writen(9, 'b')         // writing past the end grows len, so eos flips back
println("b.eos() after writen past end =", b.eos())
Output:
b.eos() at start = null
b.eos() after 1 readn('b') = null
b.eos() after 2 readn('b') = 1
b.eos() after writen past end = 1

See also

eosReturns non-null if the stream is at end-of-stream
tellReturns the current stream position
lenReturns the stream length
blobclass index