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

Commit

Permalink
Browse files Browse the repository at this point in the history
fs: don't use octal values, not allowed in strict mode
  • Loading branch information
bnoordhuis committed Nov 4, 2011
1 parent 8974ba3 commit 5fd012e
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions lib/fs.js
Expand Up @@ -19,6 +19,12 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.

// Maintainers, keep in mind that octal literals are not allowed
// in strict mode. Use the decimal value and add a comment with
// the octal value. Example:
//
// var mode = 438; /* mode=0666 */

var util = require('util');

var binding = process.binding('fs');
Expand Down Expand Up @@ -110,7 +116,7 @@ fs.readFile = function(path, encoding_) {
};

fs.readFileSync = function(path, encoding) {
var fd = fs.openSync(path, constants.O_RDONLY, 0666);
var fd = fs.openSync(path, constants.O_RDONLY, 438 /*=0666*/);
var buffer = new Buffer(4048);
var buffers = [];
var nread = 0;
Expand Down Expand Up @@ -212,13 +218,13 @@ fs.open = function(path, flags, mode, callback) {
callback = noop;
}

mode = modeNum(mode, '0666');
mode = modeNum(mode, 438 /*=0666*/);

binding.open(path, stringToFlags(flags), mode, callback);
};

fs.openSync = function(path, flags, mode) {
mode = modeNum(mode, '0666');
mode = modeNum(mode, 438 /*=0666*/);
return binding.open(path, stringToFlags(flags), mode);
};

Expand Down Expand Up @@ -565,7 +571,7 @@ fs.writeFile = function(path, data, encoding_, callback) {
var encoding = (typeof(encoding_) == 'string' ? encoding_ : 'utf8');
var callback_ = arguments[arguments.length - 1];
callback = (typeof(callback_) == 'function' ? callback_ : null);
fs.open(path, 'w', 0666, function(openErr, fd) {
fs.open(path, 'w', 438 /*=0666*/, function(openErr, fd) {
if (openErr) {
if (callback) callback(openErr);
} else {
Expand Down Expand Up @@ -986,7 +992,7 @@ var ReadStream = fs.ReadStream = function(path, options) {
this.paused = false;

this.flags = 'r';
this.mode = parseInt('0666', 8);
this.mode = 438; /*=0666*/
this.bufferSize = 64 * 1024;

options = options || {};
Expand Down Expand Up @@ -1175,7 +1181,7 @@ var WriteStream = fs.WriteStream = function(path, options) {

this.flags = 'w';
this.encoding = 'binary';
this.mode = parseInt('0666', 8);
this.mode = 438; /*=0666*/
this.bytesWritten = 0;

options = options || {};
Expand Down

0 comments on commit 5fd012e

Please sign in to comment.