iostream.stream.len
Returns the stream length
Return value
The number of bytes the stream currently holds. This does not depend on the cursor; use tell for that.
Notes
The same method works on a file, where it reports the file's size: writing past the current length grows the stream to fit, on a blob and on a writable file alike.
Example
from "iostream" import blob
let b = blob(3)
println("b.len() at start =", b.len())
b.seek(0, 'e')
b.writen(1, 'l') // writes 8 bytes past the current len of 3, growing it
println("b.len() after writen =", b.len())
b.seek(0)
println("b.len() after seek(0) =", b.len()) // seeking never changes len
println("b.tell() after seek(0) =", b.tell()) // len and tell are independentOutput:
b.len() at start = 3
b.len() after writen = 11
b.len() after seek(0) = 11
b.tell() after seek(0) = 0See also
len | Returns the stream length |
tell | Returns the current stream position |
writen | Writes a numeric value in the given format |
| stream | class index |