I'm less than, but almost a week into learning Nim and I am just getting into the Streams module. Right off the bat I noticed differences or undocumented differences from many other implementations that I have seen, which usually include a Position and Length/Size property. It looks like getPosition will satisfy one of those two, but is there a way to determine the allocated size of a stream? Otherwise how do you set the position to the end of a stream?
Hopefully my questions aren't too new'b.
Tom
For a StringStream:
var ss = newStringStream("contents")
ss.setPosition(ss.data.len)
For a FileStream, you'll need to keep a reference to the underlying File being used (the f field of the FileStream object is not exported):
var file = open("filename")
var fs = newFileStream(file)
fs.setPosition(f.getFileSize)
Fede, Thanks for the example and the warning on setPosition. Very much appreciated.
T