joyent/node — Issue #1862: Enable fs.ReadStream to remain open at the end of a file
Author: ellacochran
Created: 2011-10-11 22:52:44+00:00
State: open

In order to enable using an fs.ReadStream to follow a growing file, it should be enabled to remain open even if it reaches the end of the file.

See: http://groups.google.com/group/nodejs/browse_thread/thread/1cf4050d957e0b78

To implement this, I extended fs.ReadStream to have an option "pauseonend" which will (when set to true (default false)) pause the fs.ReadStream if the end of the file is reached rather than emitting end and destroying the Stream.
In order to be able to catch this happening and enabling a reaction to this, the fs.ReadStream.pause and fs.ReadStream.resume functions emit a pause and resume respectively if pauseonend is set.

Since this does not make sense in case a { start:#, end# } is specified this options is forced to false in case an end is specified.

This has been committed to my fork at https://github.com/ellacochran/node/commit/a6fbf74351d3f13531f0d4676b726b2b8d2a463e

I will submit a pull-request if you think this is the way to go. Otherwise, let me know and I can change things to better meet the needs of node.

Regards, Ella