Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
doc: clarify create{Read,Write}Stream fd option
Browse files Browse the repository at this point in the history
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: #7707
Fixes: #7707
Fixes: #7708
Fixes: #4367
Reviewed-By: Chris Dickinson <christopher.s.dickinson@gmail.com>
  • Loading branch information
benjamincburns authored and chrisdickinson committed Dec 16, 2014
1 parent 4bba870 commit 5b9e5bd
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions doc/api/fs.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -745,6 +745,9 @@ Returns a new ReadStream object (See `Readable Stream`).
the file instead of the entire file. Both `start` and `end` are inclusive and
start at 0. The `encoding` can be `'utf8'`, `'ascii'`, or `'base64'`.

If `fd` is specified, `ReadStream` will ignore the `path` argument and will use
the specified file descriptor. This means that no `open` event will be emitted.

If `autoClose` is false, then the file descriptor won't be closed, even if
there's an error. It is your responsibility to close it and make sure
there's no file descriptor leak. If `autoClose` is set to true (default
Expand Down Expand Up @@ -775,13 +778,19 @@ Returns a new WriteStream object (See `Writable Stream`).

{ flags: 'w',
encoding: null,
fd: null,
mode: 0666 }

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

Like `ReadStream` above, if `fd` is specified, `WriteStream` will ignore the
`path` argument and will use the specified file descriptor. This means that no
`open` event will be emitted.


## Class: fs.WriteStream

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

0 comments on commit 5b9e5bd

Please sign in to comment.