1919// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
2020// USE OR OTHER DEALINGS IN THE SOFTWARE.
2121
22- // Maintainers, keep in mind that octal literals are not allowed
23- // in strict mode. Use the decimal value and add a comment with
24- // the octal value. Example:
25- //
26- // var mode = 438; /* mode=0666 */
22+ // Maintainers, keep in mind that ES1-style octal literals (`0666`) are not
23+ // allowed in strict mode. Use ES6-style octal literals instead (`0o666`).
2724
2825'use strict' ;
2926
@@ -262,7 +259,7 @@ fs.readFile = function(path, options, callback_) {
262259 var fd ;
263260
264261 var flag = options . flag || 'r' ;
265- fs . open ( path , flag , 438 /*=0666*/ , function ( er , fd_ ) {
262+ fs . open ( path , flag , 0o666 , function ( er , fd_ ) {
266263 if ( er ) return callback ( er ) ;
267264 fd = fd_ ;
268265
@@ -352,7 +349,7 @@ fs.readFileSync = function(path, options) {
352349 assertEncoding ( encoding ) ;
353350
354351 var flag = options . flag || 'r' ;
355- var fd = fs . openSync ( path , flag , 438 /*=0666*/ ) ;
352+ var fd = fs . openSync ( path , flag , 0o666 ) ;
356353
357354 var size ;
358355 var threw = true ;
@@ -484,7 +481,7 @@ function modeNum(m, def) {
484481
485482fs . open = function ( path , flags , mode , callback ) {
486483 callback = makeCallback ( arguments [ arguments . length - 1 ] ) ;
487- mode = modeNum ( mode , 438 /*=0666*/ ) ;
484+ mode = modeNum ( mode , 0o666 ) ;
488485
489486 if ( ! nullCheck ( path , callback ) ) return ;
490487
@@ -498,7 +495,7 @@ fs.open = function(path, flags, mode, callback) {
498495} ;
499496
500497fs . openSync = function ( path , flags , mode ) {
501- mode = modeNum ( mode , 438 /*=0666*/ ) ;
498+ mode = modeNum ( mode , 0o666 ) ;
502499 nullCheck ( path ) ;
503500 return binding . open ( pathModule . _makeLong ( path ) , stringToFlags ( flags ) , mode ) ;
504501} ;
@@ -743,14 +740,14 @@ fs.mkdir = function(path, mode, callback) {
743740 var req = new FSReqWrap ( ) ;
744741 req . oncomplete = callback ;
745742 binding . mkdir ( pathModule . _makeLong ( path ) ,
746- modeNum ( mode , 511 /*=0777*/ ) ,
743+ modeNum ( mode , 0o777 ) ,
747744 req ) ;
748745} ;
749746
750747fs . mkdirSync = function ( path , mode ) {
751748 nullCheck ( path ) ;
752749 return binding . mkdir ( pathModule . _makeLong ( path ) ,
753- modeNum ( mode , 511 /*=0777*/ ) ) ;
750+ modeNum ( mode , 0o777 ) ) ;
754751} ;
755752
756753fs . readdir = function ( path , callback ) {
@@ -1069,9 +1066,9 @@ fs.writeFile = function(path, data, options, callback) {
10691066 var callback = maybeCallback ( arguments [ arguments . length - 1 ] ) ;
10701067
10711068 if ( util . isFunction ( options ) || ! options ) {
1072- options = { encoding : 'utf8' , mode : 438 /*=0666*/ , flag : 'w' } ;
1069+ options = { encoding : 'utf8' , mode : 0o666 , flag : 'w' } ;
10731070 } else if ( util . isString ( options ) ) {
1074- options = { encoding : options , mode : 438 , flag : 'w' } ;
1071+ options = { encoding : options , mode : 0o666 , flag : 'w' } ;
10751072 } else if ( ! util . isObject ( options ) ) {
10761073 throw new TypeError ( 'Bad arguments' ) ;
10771074 }
@@ -1093,9 +1090,9 @@ fs.writeFile = function(path, data, options, callback) {
10931090
10941091fs . writeFileSync = function ( path , data , options ) {
10951092 if ( ! options ) {
1096- options = { encoding : 'utf8' , mode : 438 /*=0666*/ , flag : 'w' } ;
1093+ options = { encoding : 'utf8' , mode : 0o666 , flag : 'w' } ;
10971094 } else if ( util . isString ( options ) ) {
1098- options = { encoding : options , mode : 438 , flag : 'w' } ;
1095+ options = { encoding : options , mode : 0o666 , flag : 'w' } ;
10991096 } else if ( ! util . isObject ( options ) ) {
11001097 throw new TypeError ( 'Bad arguments' ) ;
11011098 }
@@ -1124,9 +1121,9 @@ fs.appendFile = function(path, data, options, callback_) {
11241121 var callback = maybeCallback ( arguments [ arguments . length - 1 ] ) ;
11251122
11261123 if ( util . isFunction ( options ) || ! options ) {
1127- options = { encoding : 'utf8' , mode : 438 /*=0666*/ , flag : 'a' } ;
1124+ options = { encoding : 'utf8' , mode : 0o666 , flag : 'a' } ;
11281125 } else if ( util . isString ( options ) ) {
1129- options = { encoding : options , mode : 438 , flag : 'a' } ;
1126+ options = { encoding : options , mode : 0o666 , flag : 'a' } ;
11301127 } else if ( ! util . isObject ( options ) ) {
11311128 throw new TypeError ( 'Bad arguments' ) ;
11321129 }
@@ -1138,9 +1135,9 @@ fs.appendFile = function(path, data, options, callback_) {
11381135
11391136fs . appendFileSync = function ( path , data , options ) {
11401137 if ( ! options ) {
1141- options = { encoding : 'utf8' , mode : 438 /*=0666*/ , flag : 'a' } ;
1138+ options = { encoding : 'utf8' , mode : 0o666 , flag : 'a' } ;
11421139 } else if ( util . isString ( options ) ) {
1143- options = { encoding : options , mode : 438 , flag : 'a' } ;
1140+ options = { encoding : options , mode : 0o666 , flag : 'a' } ;
11441141 } else if ( ! util . isObject ( options ) ) {
11451142 throw new TypeError ( 'Bad arguments' ) ;
11461143 }
@@ -1578,7 +1575,7 @@ function ReadStream(path, options) {
15781575 this . path = path ;
15791576 this . fd = options . hasOwnProperty ( 'fd' ) ? options . fd : null ;
15801577 this . flags = options . hasOwnProperty ( 'flags' ) ? options . flags : 'r' ;
1581- this . mode = options . hasOwnProperty ( 'mode' ) ? options . mode : 438 ; /*=0666*/
1578+ this . mode = options . hasOwnProperty ( 'mode' ) ? options . mode : 0o666 ;
15821579
15831580 this . start = options . hasOwnProperty ( 'start' ) ? options . start : undefined ;
15841581 this . end = options . hasOwnProperty ( 'end' ) ? options . end : undefined ;
@@ -1746,7 +1743,7 @@ function WriteStream(path, options) {
17461743
17471744 this . fd = options . hasOwnProperty ( 'fd' ) ? options . fd : null ;
17481745 this . flags = options . hasOwnProperty ( 'flags' ) ? options . flags : 'w' ;
1749- this . mode = options . hasOwnProperty ( 'mode' ) ? options . mode : 438 ; /*=0666*/
1746+ this . mode = options . hasOwnProperty ( 'mode' ) ? options . mode : 0o666 ;
17501747
17511748 this . start = options . hasOwnProperty ( 'start' ) ? options . start : undefined ;
17521749 this . pos = undefined ;
0 commit comments