FileFollower

Up and coming: shot check knows this class and its members today, and programs run it once the native runtime lands.

ShotInstancenot creatablecomingFiles

Up and coming

Follow a growing file line by line, and carry on where you stopped after a restart.

PathHandler:FollowAsync(offset) gives one, a child of that PathHandler. It looks at the file every Interval seconds and hands over each complete line; a half-written last line waits until its end arrives. With no offset it starts at the file's current end, so only new text comes; 0 starts at the beginning. Save Offset and pass it back to carry on.

Properties

NameTypeDefaultDescription
Pathstring
OffsetnumberBytes handed over so far, to the end of the last whole line; save it to carry on after a restart.
IntervalnumberSeconds between looks at the file; 0.5 by default.
Followingboolean

Methods

NameArgumentsReturnsDescription
Pause()()
Resume()()
Stop()()

Events

NamePassesDescription
Line(string, number)Fires with each complete line, line end dropped, and the offset after it; a half-written last line waits until its end arrives.
Text(string)Fires with each new raw part of the file, for files that aren't lines.
Reset()Fires when the file got shorter or was replaced; following starts again from 0.
From ShotInstance 33