summaryrefslogtreecommitdiff
path: root/doc/api/fs.md
diff options
context:
space:
mode:
authorAnas Aboureada <anas.ieee@gmail.com>2019-02-04 17:18:39 +0100
committerRich Trott <rtrott@gmail.com>2019-08-16 23:24:02 -0700
commite4bbbcc84bd10be1e9e8e66d42542c70c1a02056 (patch)
treeb68c4aab9bf147c9670df4acb171b34857bf195f /doc/api/fs.md
parent5e3b4d6ed957ca03ae7178c7697549f470b6d86e (diff)
downloadandroid-node-v8-e4bbbcc84bd10be1e9e8e66d42542c70c1a02056.tar.gz
android-node-v8-e4bbbcc84bd10be1e9e8e66d42542c70c1a02056.tar.bz2
android-node-v8-e4bbbcc84bd10be1e9e8e66d42542c70c1a02056.zip
fs: add fs.writev() which exposes syscall writev()
fs with writev allow many buffers to be pushed to underlying OS APIs in one batch, so this should improve write speed to files. Refs: https://github.com/nodejs/node/issues/2298 PR-URL: https://github.com/nodejs/node/pull/25925 Fixes: https://github.com/nodejs/node/issues/2298 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
Diffstat (limited to 'doc/api/fs.md')
-rw-r--r--doc/api/fs.md47
1 files changed, 47 insertions, 0 deletions
diff --git a/doc/api/fs.md b/doc/api/fs.md
index c369a579e2..d71f8afd82 100644
--- a/doc/api/fs.md
+++ b/doc/api/fs.md
@@ -3863,6 +3863,52 @@ changes:
For detailed information, see the documentation of the asynchronous version of
this API: [`fs.write(fd, string...)`][].
+## fs.writev(fd, buffers[, position], callback)
+<!-- YAML
+added: REPLACEME
+-->
+
+* `fd` {integer}
+* `buffers` {ArrayBufferView[]}
+* `position` {integer}
+* `callback` {Function}
+ * `err` {Error}
+ * `bytesWritten` {integer}
+ * `buffers` {ArrayBufferView[]}
+
+Write an array of `ArrayBufferView`s to the file specified by `fd` using
+`writev()`.
+
+`position` is the offset from the beginning of the file where this data
+should be written. If `typeof position !== 'number'`, the data will be written
+at the current position.
+
+The callback will be given three arguments: `err`, `bytesWritten`, and
+`buffers`. `bytesWritten` is how many bytes were written from `buffers`.
+
+If this method is [`util.promisify()`][]ed, it returns a `Promise` for an
+`Object` with `bytesWritten` and `buffers` properties.
+
+It is unsafe to use `fs.writev()` multiple times on the same file without
+waiting for the callback. For this scenario, use [`fs.createWriteStream()`][].
+
+On Linux, positional writes don't work when the file is opened in append mode.
+The kernel ignores the position argument and always appends the data to
+the end of the file.
+
+## fs.writevSync(fd, buffers[, position])
+<!-- YAML
+added: REPLACEME
+-->
+
+* `fd` {integer}
+* `buffers` {ArrayBufferView[]}
+* `position` {integer}
+* Returns: {number} The number of bytes written.
+
+For detailed information, see the documentation of the asynchronous version of
+this API: [`fs.writev()`][].
+
## fs Promises API
The `fs.promises` API provides an alternative set of asynchronous file system
@@ -5113,6 +5159,7 @@ the file contents.
[`fs.write(fd, buffer...)`]: #fs_fs_write_fd_buffer_offset_length_position_callback
[`fs.write(fd, string...)`]: #fs_fs_write_fd_string_position_encoding_callback
[`fs.writeFile()`]: #fs_fs_writefile_file_data_options_callback
+[`fs.writev()`]: #fs_fs_writev_fd_buffers_position_callback
[`inotify(7)`]: http://man7.org/linux/man-pages/man7/inotify.7.html
[`kqueue(2)`]: https://www.freebsd.org/cgi/man.cgi?query=kqueue&sektion=2
[`net.Socket`]: net.html#net_class_net_socket