0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-30 23:43:09 +01:00
Commit Graph

145 Commits

Author SHA1 Message Date
Johannes Wüller
0803962860 fs: add file descriptor support to *File() funcs
These changes affect the following functions and their synchronous
counterparts:

 * fs.readFile()
 * fs.writeFile()
 * fs.appendFile()

If the first parameter is a uint32, it is treated as a file descriptor.
In all other cases, the original implementation is used to ensure
backwards compatibility. File descriptor ownership is never taken from
the user.

The documentation was adjusted to reflect these API changes. A note was
added to make the user aware of file descriptor ownership and the
conditions under which a file descriptor can be used by each of these
functions.

Tests were extended to test for file descriptor parameters under the
conditions noted in the relevant documentation.

PR-URL: https://github.com/nodejs/node/pull/3163
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
2015-10-16 17:14:21 -06:00
Rich Trott
0e4b772d6c doc: copyedit fs.watch() information
Removed "Only FSEvents supports this type of file watching so it is
unlikely any additional platforms will be added soon."

Per @saghul, "FSEvents" refers to the OSX API, but since we added
Windows support it may not be  unlikely that we add more.

PR-URL: https://github.com/nodejs/node/pull/3097
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: Michaël Zasso <mic.besace@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2015-09-29 23:32:23 -07:00
Yazhong Liu
1f842c2c61 fs: consider NaN/Infinity in toUnixTimestamp
PR-URL: https://github.com/nodejs/node/pull/2387
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
2015-09-14 16:55:15 -06:00
Sakthipriyan Vairamani
f0a75ab2d3 doc,test: enable recursive file watching in Windows
Recursive file watching is supported by libuv since 1.7.0. Refer
https://github.com/nodejs/node/blob/master/deps/uv/ChangeLog#L126. This
patch notes that in the docs and enables testing this feature. It also
adds proper TAP plugin parsable message for other platforms.

PR-URL: https://github.com/nodejs/node/pull/2649
Fixes: https://github.com/nodejs/node/issues/375
Reviewed-By: rvagg - Rod Vagg <rod@vagg.org>
Reviewed-By: silverwind - Roman Reiss <me@silverwind.io>
2015-09-06 21:38:07 +10:00
James M Snell
281be6ce65 doc: fix minor types and grammar in fs docs
per: https://github.com/joyent/node/pull/7431

originally submitted by @linclark

Reviewed By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/2378
2015-08-25 18:52:13 -07:00
James M Snell
7860977524 doc: update description of fs.exists in fs.markdown
per: https://github.com/joyent/node/pull/7944

originally submitted by @oconnore

Minor update to the description in `fs.exists()`

Reviewed By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/2378
2015-08-25 18:51:57 -07:00
Sakthipriyan Vairamani
5c77031f95 doc: make the deprecations consistent
The deprecation messages in the documentations should be in the format

    Stability: 0 - Deprecated: Use [alternate] instead.

so that they will be consistent.

PR-URL: https://github.com/nodejs/node/pull/2450
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: James M Snell <jasnell@gmail.com>
2015-08-24 13:38:37 +05:30
cjihrig
a69ab27ab4 node: rename from io.js to node
This commit replaces instances of io.js with Node.js, based on the
recent convergence. There are some remaining instances of io.js,
related to build and the installer.

Fixes: https://github.com/nodejs/node/issues/2361
PR-URL: https://github.com/nodejs/node/pull/2367
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: João Reis <reis@janeasystems.com>
2015-08-23 17:59:43 -04:00
Rich Trott
3ba9793d53 doc: clarify options for fs.watchFile()
The explanation for the `options` argument to `fs.watchFile()` had
missing punctuation. I took the opportunity to try to rewrite the
paragraph for greater clarity.

PR-URL: https://github.com/nodejs/node/pull/2425
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: Brendan Ashworth <brendan.ashworth@me.com>
2015-08-18 11:07:16 -07:00
James M Snell
936c9ffb0f doc: multiple documentation updates cherry picked from v0.12
* doc: improve http.abort description
 * doc: mention that mode is ignored if file exists
 * docs: Fix default options for fs.createWriteStream()
 * Documentation update about Buffer initialization
 * doc: add a note about readable in flowing mode
 * doc: Document http.request protocol option
 * doc, comments: Grammar and spelling fixes
 * updated documentation for fs.createReadStream
 * Update child_process.markdown, spelling
 * doc: Clarified read method with specified size argument.
 * docs:events clarify emitter.listener() behavior
 * doc: two minor stream doc improvements
 * doc: clarify Readable._read and Readable.push
 * doc: stream.unshift does not reset reading state
 * doc: readable event clarification
 * doc: additional refinement to readable event

Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ben Noorduis <ben@strongloop.com>
PR-URL: https://github.com/nodejs/io.js/pull/2302
2015-08-05 08:44:55 -07:00
Sakthipriyan Vairamani
ed85c95a9c doc,test: documents behaviour of non-existent file
As per the discussion in
https://github.com/nodejs/io.js/pull/2093#discussion_r34343965, this
patch documents the behavior of calling fs.watchFile() with a path that
does not yet exist.

This patch also includes a test which checks if a file not present, the
callback is invoked at least once and if the file is created after
the callback is invoked, it will be invoked again with new stat
objects.

PR-URL: https://github.com/nodejs/io.js/pull/2169
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Brendan Ashworth <brendan.ashworth@me.com>
2015-08-04 22:31:01 +05:30
Yosuke Furukawa
4ef2b5fbfb doc: Replace util.debug with console.error
PR-URL: https://github.com/nodejs/io.js/pull/2214
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
2015-07-24 02:45:32 +09:00
Brendan Ashworth
23efb05cc3 doc: document fs.watchFile behaviour on ENOENT
When fs.watchFile encounters an ENOENT error, it invokes the given
callback with some error data. This caused an issue as it was different
behaviour than Node v0.10. Instead of changing this behaviour, document
it and add a test.

Ref: https://github.com/nodejs/io.js/issues/1745
Ref: https://github.com/nodejs/io.js/pull/2028
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
PR-URL: https://github.com/nodejs/io.js/pull/2093
2015-07-10 14:24:50 -07:00
Yosuke Furukawa
353e26e3c7 fs: Add string encoding option for Stream method
Add string encoding option for fs.createReadStream and
fs.createWriteStream. and check argument type more strictly

PR-URL: https://github.com/nodejs/io.js/pull/1845
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2015-06-05 10:30:32 +09:00
Yosuke Furukawa
8357c5084b fs: set encoding on fs.createWriteStream
Enable encoding option on fs.createWriteStream.

PR-URL: https://github.com/nodejs/io.js/pull/1844
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2015-06-03 03:01:35 +09:00
Tyler Anton
a79dece8ad docs: add return value for sync fs functions
Clarify that synchronous functions in fs with no return value return
undefined.

Specify that fs.openSync() returns an integer and fs.existsSync()
returns true or false.

Fixes: https://github.com/joyent/node/issues/9313

PR: https://github.com/joyent/node/pull/9359
Reviewed-By: Julien Gilli <julien.gilli@joyent.com>

PORT-FROM: joyent/node @ 51fe319faf
PR-URL: https://github.com/nodejs/io.js/pull/1770
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>

Conflicts:
	doc/api/fs.markdown
2015-06-01 14:11:10 -04:00
Rich Trott
ff794498e7 doc: fs.*File() also accept encoding strings
Fixes: https://github.com/nodejs/io.js/issues/1797
PR-URL: https://github.com/nodejs/io.js/pull/1806
Reviewed-By: fishrock123@rocketmail.com
2015-05-27 15:53:14 -04:00
Rich Trott
eb1856dfd1 doc: clarify stability of fs.watch and relatives
Fixes: https://github.com/nodejs/io.js/issues/1754
PR-URL: https://github.com/nodejs/io.js/pull/1775
Reviewed-By: Brendan Ashworth <brendan.ashworth@me.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
2015-05-26 11:26:02 -04:00
Benjamin Gruenbaum
c380ac6e98 doc: suggest alternatives to deprecated APs
At the moment users who want to use `fs.exists` get a warning that the
method is deprecated but do not get offered an alternative in the page.
This PR suggests `fs.stat` and `fs.access` as alternatives while
keeping the warning about the use case in place.

Fixes: https://github.com/iojs/io.js/issues/1002
PR-URL: https://github.com/iojs/io.js/pull/1007
Reviewed-By: Brian White <mscdex@mscdex.net>
Reviewed-By: Christian Tellnes <christian@tellnes.no>
2015-03-01 18:46:28 +01:00
Chris Dickinson
cf0306cd71 doc: update stability index
This simplifies the stability index to 4 levels:

0 - deprecated
1 - experimental / feature-flagged
2 - stable
3 - locked

Domains has been downgraded to deprecated, assert has been
downgraded to stable. Timers and Module remain locked. All
other APIs are now stable.

PR-URL: https://github.com/iojs/io.js/pull/943
Fixes: https://github.com/iojs/io.js/issues/930
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: Vladimir Kurchatkin <vladimir.kurchatkin@gmail.com>
2015-02-27 14:23:01 -08:00
Bruno Jouhier
c82e580a50 fs: properly handle fd passed to truncate()
Currently, fs.truncate() silently fails when a file descriptor
is passed as the first argument. This commit changes this
behavior to properly call fs.ftruncate().

PR-URL: https://github.com/joyent/node/pull/9161
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Timothy J Fontaine <tjfontaine@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>

Conflicts:
	lib/fs.js
2015-02-21 12:13:21 -05:00
Dan Dascalescu
30dca66958 doc: fix code syntax
Add a ';' to the end of a function call in documentation.

PR-URL: https://github.com/joyent/node/pull/9198
Reviewed-by: Trevor Norris <trev.norris@gmail.com>
2015-02-13 13:37:25 -05:00
Rudolf Meijering
15d156e3ec doc: fix wording in fs.appendFile
PR-URL: https://github.com/iojs/io.js/pull/801
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
2015-02-11 10:42:25 -05:00
Ben Noordhuis
789bbb91d3 doc: update node.js references in api docs
Fixes: https://github.com/iojs/io.js/issues/740
PR-URL: https://github.com/iojs/io.js/pull/750
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2015-02-07 17:07:15 -05:00
Bert Belder
5843ae8dfb Revert "doc: clarify fs.symlink and fs.symlinkSync parameters"
The offending doc change clarified nothing, but put the arguments to
fs.symlink() and fs.symlinkSync() in the wrong order.

This reverts commit 8146f2e607.

BUG: https://github.com/joyent/node/issues/8920
PR: https://github.com/joyent/node/pull/8936
2015-01-27 19:18:23 +01:00
Vladimir Kurchatkin
7f9a6c6213 fs: use ES6 octal literals for mode
Update docs, comments and code to use ES6 octal literals instead of
decimal + comment.

PR-URL: https://github.com/iojs/io.js/pull/281
Reviewed-by: Bert Belder <bertbelder@gmail.com>
Reviewed-by: Colin Ihrig <cjihrig@gmail.com>
2015-01-11 00:46:23 +01:00
Ben Noordhuis
94e147500c Merge remote-tracking branch 'joyent/v0.12' into v1.x
I was originally going to do this after the v0.11.15 release, but as
that release is three weeks overdue now, I decided not to wait any
longer; we don't want the delta to get too big.

Conflicts:
	lib/net.js
	test/simple/simple.status

PR-URL: https://github.com/iojs/io.js/pull/236
Reviewed-By: Bert Belder <bertbelder@gmail.com>
Reviewed-By: Fedor Indutny <fedor@indutny.com>
2015-01-05 17:26:47 +01:00
cjihrig
5678595856 fs: deprecate exists() and existsSync()
These methods don't follow standard conventions, and shouldn't
be used anyway.

Fixes: https://github.com/iojs/io.js/issues/103
PR-URL: https://github.com/iojs/io.js/pull/166
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2014-12-19 10:27:48 -05:00
Ben Burns
5b9e5bdd03 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: https://github.com/joyent/node/issues/7707
Fixes: https://github.com/joyent/node/issues/7707
Fixes: https://github.com/joyent/node/issues/7708
Fixes: https://github.com/joyent/node/issues/4367
Reviewed-By: Chris Dickinson <christopher.s.dickinson@gmail.com>
2014-12-15 22:25:58 -08:00
cjihrig
165b70f146 fs: add access() and accessSync()
fs.exists() and fs.existsSync() do not follow the typical
error first callback convention. access() and accessSync()
are added as alternatives in this commit.

Fixes: https://github.com/joyent/node/pull/8714
PR-URL: https://github.com/iojs/io.js/pull/114
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Domenic Denicola <domenic@domenicdenicola.com>
2014-12-15 12:05:49 -05:00
Trevor Norris
f2a78de6ec doc: fix optional parameter parsing
The parameter parser specifically looked for the old bracket syntax.
This generated a lot of warnings when building the docs. Those warnings
have been fixed by changing the parsing logic.

Signed-off-by: Trevor Norris <trev.norris@gmail.com>
2014-09-29 16:32:34 -07:00
Trevor Norris
51b6b6844e doc: fix brackets for optional parameters
Documentation incorrectly used bracket notation for optional parameters.
This caused inconsistencies in usage because of examples like the
following:

    fs.write(fd, data[, position[, encoding]], callback)

This simply fixes all uses of bracket notation in documentation.

Signed-off-by: Trevor Norris <trev.norris@gmail.com>
Reviewed-by: Fedor Indutny <fedor@indutny.com>
2014-09-25 11:26:15 -07:00
Benjamin Waters
8c4b2c35a4 doc: Missing word 'are' in documentation
Fix simple spelling mistake in documentation.

fix #5808
2013-12-26 21:17:19 +04:00
Nick Simmons
691b9ebc8c fs: add recursive subdirectory support to fs.watch
Currently fs.watch does not have an option to specify if a directory
should be recursively watched for events across all subdirectories.

Several file watcher APIs support this. FSEvents on OS X > 10.5 is
one example. libuv has added support for FSEvents, but fs.watch had
no way to specify that a recursive watch was required.

fs.watch now has an additional boolean option 'recursive'. When set
to true, and when supported, fs.watch will return notifications for
the entire directory tree hierarchy rooted at the specified path.
2013-10-31 01:13:44 +04:00
isaacs
0396b20ff4 Merge remote-tracking branch 'ry/v0.10' 2013-10-28 14:12:00 -07:00
Phillip Alexander
977c54adb5 doc: fs: clarify fs.symlink Windows specific args 2013-10-27 21:02:19 +01:00
Timothy J Fontaine
61ccaf9a97 Merge remote-tracking branch 'upstream/v0.10'
Conflicts:
	ChangeLog
	deps/uv/ChangeLog
	deps/uv/include/uv-darwin.h
	deps/uv/src/unix/fsevents.c
	deps/uv/src/unix/process.c
	deps/uv/src/version.c
	doc/api/addons.markdown
	doc/api/cluster.markdown
	doc/api/http.markdown
	lib/http.js
	lib/tls.js
	src/node_crypto.cc
	src/node_http_parser.cc
	src/node_version.h
	src/pipe_wrap.cc
	src/v8abbr.h
	src/v8ustack.d
	test/simple/test-http-pipeline-flood.js
2013-10-25 11:26:05 -07:00
Ben Noordhuis
d97ea06d88 doc: add warning to fs.exists() documentation
Warn against the open-if-exists anti-pattern, it's susceptible to
race conditions.
2013-10-05 14:54:57 +02:00
isaacs
645418e9f1 fs: Expose birthtime on stat objects
Just do the best we can with whatever libuv gives us.

Also, document the semantics of `ctime` and the compatibility with
Windows.
2013-08-27 10:42:18 -07:00
Timothy J Fontaine
b26d346b57 Merge remote-tracking branch 'upstream/v0.10'
Conflicts:
	deps/v8/test/cctest/test-api.cc
	lib/events.js
	lib/http.js
2013-08-06 11:59:17 -07:00
Sam Roberts
6a7be99703 doc: fs.open, fix flag/mode confusion, etc.
Flags and modes aren't the same, symlinks are followed in all of the
path but the last component, docs should say something about what the
mode argument is for and when its used, fs.openSync should point to the
function that contains the docs for its args, as fs.writeSync does.
2013-08-05 12:26:09 +02:00
Trevor Norris
7ca77eaf38 fs: write strings directly to disk
Prior, strings would first be converted to a Buffer before being written
to disk. Now the intermediary step has been removed.

Other changes of note:

* Class member "must_free" was added to req_wrap so to track if the
  memory needs to be manually cleaned up after use.
* External String Resource support, so the memory will be used directly
  instead of copying out the data.
* Docs have been updated to reflect that if position is not a number
  then it will assume null. Previously it specified the argument must be
  null, but that was not how the code worked. An attempt was made to
  only support == null, but there were too many tests that assumed !=
  number would be enough.
* Docs update show some of the write/writeSync arguments are optional.
2013-07-30 14:42:30 -07:00
Ben Noordhuis
b8c04b921b Merge remote-tracking branch 'origin/v0.10'
Conflicts:
	AUTHORS
	ChangeLog
	deps/uv/ChangeLog
	deps/uv/src/version.c
	deps/uv/src/win/fs.c
	src/node.cc
	src/node_crypto.cc
	src/node_os.cc
	src/node_version.h
2013-07-30 15:19:48 +02:00
Ben Noordhuis
4881a6a9a3 doc: clarify fs.read() offset argument 2013-07-28 00:05:10 +02:00
isaacs
adf9b67e59 Merge remote-tracking branch 'ry/v0.10' into master
Conflicts:
	ChangeLog
	deps/uv/ChangeLog
	deps/uv/src/unix/stream.c
	deps/uv/src/version.c
	deps/v8/build/common.gypi
	deps/v8/src/frames.h
	deps/v8/src/runtime.cc
	deps/v8/test/mjsunit/debug-set-variable-value.js
	lib/http.js
	src/node_version.h
2013-06-25 11:12:33 -07:00
Ben Noordhuis
3fac4157fe doc: fs: synchronize watchFile/unwatchFile warning
One said "if available", the other "if possible". Now they both say
"if possible."
2013-06-24 11:18:24 +02:00
isaacs
2900f0778a Merge remote-tracking branch 'ry/v0.10'
Conflicts:
	ChangeLog
	src/node_version.h
2013-05-31 11:52:57 -07:00
Kiyoshi Nomo
36e90da6df doc: remove bufferSize option
`bufferSize` option has been removed in b0f6789.
2013-05-30 15:10:03 +02:00
isaacs
61c9f78c63 Merge remote-tracking branch 'ry/v0.10' into master
Conflicts:
	AUTHORS
	ChangeLog
	deps/uv/ChangeLog
	deps/uv/config-unix.mk
	deps/uv/src/unix/stream.c
	deps/uv/src/version.c
	deps/uv/uv.gyp
	src/node.cc
	src/node_buffer.cc
	src/node_crypto.cc
	src/node_version.h
	src/stream_wrap.cc
	src/stream_wrap.h
2013-05-17 14:04:54 -07:00
Ryuichi Okumura
4cd643ee2d doc: fix missing Class in header 2013-05-16 16:56:56 +02:00