You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fs.read documentation does not specify how to detect EOF condition #35363
As far as I can tell, neither fs.read nor FileHandle#read specify how to detect when the end of a file has been reached, nor can I find this information elsewhere in the fs documentation.
The fs.createReadStream implementation suggests that the answer to this question is "when bytesRead is 0", but this should be added to the documentation if that is indeed the correct way to detect this condition.
The docs probably implicitly assume familiarity with man 2 read but to not keep you in suspense any longer: you detect it by observing a short read (fewer bytes than you requested, possibly zero) but, caveat emptor, the next read can return more bytes if the file was modified concurrently.
Activity
bnoordhuis commentedon Sep 27, 2020
The docs probably implicitly assume familiarity with
man 2 readbut to not keep you in suspense any longer: you detect it by observing a short read (fewer bytes than you requested, possibly zero) but, caveat emptor, the next read can return more bytes if the file was modified concurrently.Documentation pull request welcome.
doc: specify how to detect EOF
doc: specify how to detect EOF