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
Function fs.readFile should understand both file name and file descriptor as the first argument, it's specified in docs for Node.js v4.x.
I try to use code like this:
var fs = require('fs');
var filename = './test/test.json';
fs.open(filename, 'r', function (err, fh) {
console.log(arguments);
fs.readFile(fh, 'utf8', function () {
console.log(arguments);
});
});
And I got that output:
{ '0': null, '1': 9 }
fs.js:250
binding.open(pathModule._makeLong(path),
^
TypeError: path must be a string
at TypeError (native)
at Object.fs.readFile (fs.js:250:11)
at /home/ubuntu/workspace/temp.js:7:8
at FSReqWrap.oncomplete (fs.js:82:15)
My software version:
$ node --version
v4.4.1
$ uname -a
Linux topal-file_storage-2753437 4.2.0-c9 #1 SMP Fri Nov 20 14:49:01 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
File descriptor support was added with #3163 and it was decided at that time not to backport this change to LTS.
This is actually an error in the documentation that was introduced by 3a8f4b2
cc @nodejs/lts @tflanagan
There could be other similar mistakes in this commit or others from the sort documentation PR
Activity
targos commentedon Mar 23, 2016
File descriptor support was added with #3163 and it was decided at that time not to backport this change to LTS.
This is actually an error in the documentation that was introduced by 3a8f4b2
cc @nodejs/lts @tflanagan
There could be other similar mistakes in this commit or others from the sort documentation PR
cjihrig commentedon Mar 23, 2016
FWIW, I have verified that the code runs correctly on v5.
jasnell commentedon Mar 23, 2016
@targos ... good catch on that. @ToPal ... would you be interested in helping out with a PR to fix the documentation? :-)
doc: updated fs
doc: updated fs
ToPal commentedon Mar 23, 2016
@jasnell I would :)
Pull request for branch
nodejs:v4.xis readydoc: updated fs
doc: updated fs
doc: updated fs #5862 removed irrelevant data in fs.markdown
thefourtheye commentedon Mar 27, 2016
Closing as #5877 landed. Thanks @ToPal :-)
doc: updated fs #5862 removed irrelevant data in fs.markdown
doc: updated fs #5862 removed irrelevant data in fs.markdown