iostream.stream.eos
Returns non-null if the stream is at end-of-stream
from "iostream" import blob
let ammo = blob(0)
ammo.writen(200, 'i')
println("ammo.eos() =", ammo.eos())Output:
ammo.eos() = 1Return 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
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') = 1See also
eos | Returns non-null if the stream is at end-of-stream |
tell | Returns the current stream position |
len | Returns the stream length |
| stream | class index |