fs: don't use octal values, not allowed in strict mode
This commit is contained in:
parent
8974ba31a3
commit
5fd012e67a
18
lib/fs.js
18
lib/fs.js
@ -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');
|
||||
@ -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;
|
||||
@ -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);
|
||||
};
|
||||
|
||||
@ -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 {
|
||||
@ -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 || {};
|
||||
@ -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 || {};
|
||||
|
Loading…
x
Reference in New Issue
Block a user