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
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 text was updated successfully, but these errors were encountered:
ChALkeR
added
doc
Issues and PRs related to the documentations.
fs
Issues and PRs related to the fs subsystem / file system.
labels
Sep 26, 2020
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.
Specify how to detect end-of-file when using `fs.read()` and
`filehandle.read()`.
PR-URL: #35445Fixes: #35363
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Zeyu Yang <himself65@outlook.com>
Reviewed-By: Andrey Pechkurov <apechkurov@gmail.com>
joesepi
pushed a commit
to joesepi/node
that referenced
this issue
Jan 8, 2021
Specify how to detect end-of-file when using `fs.read()` and
`filehandle.read()`.
PR-URL: nodejs#35445Fixes: nodejs#35363
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Zeyu Yang <himself65@outlook.com>
Reviewed-By: Andrey Pechkurov <apechkurov@gmail.com>
As far as I can tell, neither
fs.read
norFileHandle#read
specify how to detect when the end of a file has been reached, nor can I find this information elsewhere in thefs
documentation.The
fs.createReadStream
implementation suggests that the answer to this question is "whenbytesRead
is 0", but this should be added to the documentation if that is indeed the correct way to detect this condition.The text was updated successfully, but these errors were encountered: