How do I change the point I start reading a Stream?
I have a stream that I read out until the end. I then append more content to the stream and want to read out only what has been added. How do I only read out the new contents of the stream? Essentially, I want to read a stream, record the end position, then once the stream is updated read the contents from that recorded position until at the new end. This stream needs to be kept intact for historical reference so cannot be cleared between reads. Also, it needs to be read out at these separate times in this context to provide progress updates to the user as the time between these reads could be significant.
Is this possible in Caché/IRIS?
Comments
You might be able to use the Size property to keep track of the initial size of the stream, write some more data, then use MoveTo() to rewind back to where you started writing:
set stream = ##class(%Stream.FileCharacter).%New()
do stream.Write("hello world!")
set tmpSize = stream.Size
do stream.Write("goodbye world!")
do stream.MoveTo(tmpSize + 1)
write stream.Read()This is exactly what I was looking for, did not realize this was a method as I was instead looking at the private position property. Thank you!