Quirrel4.41.0

iostream.stream.eos

Method of stream, from module "iostream"

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

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

let ammo = blob(0)
ammo.writen(200, 'i')
println("ammo.eos() =", ammo.eos())
Output:
ammo.eos() = 1

Return value

1 when tell() == len(), null otherwise. It is computed fresh from both on every call, not a sticky flag that a later seek or write leaves behind.

Notes

The same method works on a file. A read or write that consumes exactly the last remaining byte lands the cursor on len(), so eos turns non-null right after that call, before any further read is attempted.

Example

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

let b = blob(0)
println("b.eos() at start =", b.eos())         // len 0, cursor 0: already at the end
b.writen(0x11223344, 'i')
println("b.eos() after writen =", b.eos())         // the write advanced the cursor exactly to the new len
b.seek(0)
println("b.eos() after seek(0) =", b.eos())         // cursor moved back, len did not
b.seek(0, 'e')
println("b.eos() after seek(0, 'e') =", b.eos())
Output:
b.eos() at start = 1
b.eos() after writen = 1
b.eos() after seek(0) = null
b.eos() after seek(0, 'e') = 1

See also

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