Skip to content

Commit 5b9e5bd

Browse files
benjamincburnschrisdickinson
authored andcommitted
doc: clarify create{Read,Write}Stream fd option
Clarify the fd option: it is preferred to the path parameter, omits the "open" event if given, and is available on WriteStreams as well. PR-URL: nodejs/node-v0.x-archive#7707 Fixes: nodejs/node-v0.x-archive#7707 Fixes: nodejs/node-v0.x-archive#7708 Fixes: nodejs/node-v0.x-archive#4367 Reviewed-By: Chris Dickinson <christopher.s.dickinson@gmail.com>
1 parent 4bba870 commit 5b9e5bd

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

doc/api/fs.markdown

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -745,6 +745,9 @@ Returns a new ReadStream object (See `Readable Stream`).
745745
the file instead of the entire file. Both `start` and `end` are inclusive and
746746
start at 0. The `encoding` can be `'utf8'`, `'ascii'`, or `'base64'`.
747747

748+
If `fd` is specified, `ReadStream` will ignore the `path` argument and will use
749+
the specified file descriptor. This means that no `open` event will be emitted.
750+
748751
If `autoClose` is false, then the file descriptor won't be closed, even if
749752
there's an error. It is your responsibility to close it and make sure
750753
there's no file descriptor leak. If `autoClose` is set to true (default
@@ -775,13 +778,19 @@ Returns a new WriteStream object (See `Writable Stream`).
775778

776779
{ flags: 'w',
777780
encoding: null,
781+
fd: null,
778782
mode: 0666 }
779783

780784
`options` may also include a `start` option to allow writing data at
781785
some position past the beginning of the file. Modifying a file rather
782786
than replacing it may require a `flags` mode of `r+` rather than the
783787
default mode `w`.
784788

789+
Like `ReadStream` above, if `fd` is specified, `WriteStream` will ignore the
790+
`path` argument and will use the specified file descriptor. This means that no
791+
`open` event will be emitted.
792+
793+
785794
## Class: fs.WriteStream
786795

787796
`WriteStream` is a [Writable Stream](stream.html#stream_class_stream_writable).

0 commit comments

Comments
 (0)