Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fs: No need for fs.readFile mode option

  • Loading branch information...
commit 5b2b19b9ba4bfdc3ee579e051e13c085585c6649 1 parent 2e4d149
isaacs authored
Showing with 7 additions and 9 deletions.
  1. +0 −1  doc/api/fs.markdown
  2. +7 −8 lib/fs.js
1  doc/api/fs.markdown
View
@@ -415,7 +415,6 @@ Synchronous version of `fs.read`. Returns the number of `bytesRead`.
* `filename` {String}
* `options` {Object}
* `encoding` {String | Null} default = `null`
- * `mode` {Number} default = `438` (aka `0666` in Octal)
* `flag` {String} default = `'r'`
Asynchronously reads the entire contents of a file. Example:
15 lib/fs.js
View
@@ -169,11 +169,11 @@ fs.readFile = function(path, options, callback_) {
var callback = maybeCallback(arguments[arguments.length - 1]);
if (typeof options === 'function' || !options) {
- options = { encoding: null, mode: 438 /*=0666*/, flag: 'r' };
+ options = { encoding: null, flag: 'r' };
} else if (typeof options === 'string') {
- options = { encoding: options, mode: 438, flag: 'r' };
+ options = { encoding: options, flag: 'r' };
} else if (!options) {
- options = { encoding: null, mode: 438 /*=0666*/, flag: 'r' };
+ options = { encoding: null, flag: 'r' };
} else if (typeof options !== 'object') {
throw new TypeError('Bad arguments');
}
@@ -189,7 +189,7 @@ fs.readFile = function(path, options, callback_) {
var fd;
var flag = options.flag || 'r';
- fs.open(path, flag, options.mode, function(er, fd_) {
+ fs.open(path, flag, 438 /*=0666*/, function(er, fd_) {
if (er) return callback(er);
fd = fd_;
@@ -256,9 +256,9 @@ fs.readFile = function(path, options, callback_) {
fs.readFileSync = function(path, options) {
if (!options) {
- options = { encoding: null, mode: 438 /*=0666*/, flag: 'r' };
+ options = { encoding: null, flag: 'r' };
} else if (typeof options === 'string') {
- options = { encoding: options, mode: 438, flag: 'r' };
+ options = { encoding: options, flag: 'r' };
} else if (typeof options !== 'object') {
throw new TypeError('Bad arguments');
}
@@ -266,9 +266,8 @@ fs.readFileSync = function(path, options) {
var encoding = options.encoding;
assertEncoding(encoding);
- var mode = options.mode || 438;
var flag = options.flag || 'r';
- var fd = fs.openSync(path, flag, mode);
+ var fd = fs.openSync(path, flag, 438 /*=0666*/);
var size;
var threw = true;
Please sign in to comment.
Something went wrong with that request. Please try again.