@@ -37,18 +37,18 @@ var EventEmitter = require('events').EventEmitter;
3737var kMinPoolSpace = 128 ;
3838var kPoolSize = 40 * 1024 ;
3939
40- var O_APPEND = constants . O_APPEND || 0 ;
41- var O_CREAT = constants . O_CREAT || 0 ;
40+ var O_APPEND = constants . O_APPEND || 0 ;
41+ var O_CREAT = constants . O_CREAT || 0 ;
4242var O_DIRECTORY = constants . O_DIRECTORY || 0 ;
43- var O_EXCL = constants . O_EXCL || 0 ;
44- var O_NOCTTY = constants . O_NOCTTY || 0 ;
45- var O_NOFOLLOW = constants . O_NOFOLLOW || 0 ;
46- var O_RDONLY = constants . O_RDONLY || 0 ;
47- var O_RDWR = constants . O_RDWR || 0 ;
48- var O_SYMLINK = constants . O_SYMLINK || 0 ;
49- var O_SYNC = constants . O_SYNC || 0 ;
50- var O_TRUNC = constants . O_TRUNC || 0 ;
51- var O_WRONLY = constants . O_WRONLY || 0 ;
43+ var O_EXCL = constants . O_EXCL || 0 ;
44+ var O_NOCTTY = constants . O_NOCTTY || 0 ;
45+ var O_NOFOLLOW = constants . O_NOFOLLOW || 0 ;
46+ var O_RDONLY = constants . O_RDONLY || 0 ;
47+ var O_RDWR = constants . O_RDWR || 0 ;
48+ var O_SYMLINK = constants . O_SYMLINK || 0 ;
49+ var O_SYNC = constants . O_SYNC || 0 ;
50+ var O_TRUNC = constants . O_TRUNC || 0 ;
51+ var O_WRONLY = constants . O_WRONLY || 0 ;
5252
5353fs . Stats = binding . Stats ;
5454
@@ -199,18 +199,18 @@ function stringToFlags(flag) {
199199 }
200200
201201 switch ( flag ) {
202- case 'r' : return O_RDONLY ;
202+ case 'r' : return O_RDONLY ;
203203 case 'r+' : return O_RDWR ;
204204
205- case 'w' : return O_TRUNC | O_CREAT | O_WRONLY ;
205+ case 'w' : return O_TRUNC | O_CREAT | O_WRONLY ;
206206 case 'wx' : // fall through
207207 case 'xw' : return O_TRUNC | O_CREAT | O_WRONLY | O_EXCL ;
208208
209209 case 'w+' : return O_TRUNC | O_CREAT | O_RDWR ;
210210 case 'wx+' : // fall through
211211 case 'xw+' : return O_TRUNC | O_CREAT | O_RDWR | O_EXCL ;
212212
213- case 'a' : return O_APPEND | O_CREAT | O_WRONLY ;
213+ case 'a' : return O_APPEND | O_CREAT | O_WRONLY ;
214214 case 'ax' : // fall through
215215 case 'xa' : return O_APPEND | O_CREAT | O_WRONLY | O_EXCL ;
216216
@@ -262,8 +262,10 @@ fs.open = function(path, flags, mode, callback) {
262262
263263 mode = modeNum ( mode , 438 /*=0666*/ ) ;
264264
265- binding . open ( pathModule . _makeLong ( path ) , stringToFlags ( flags ) , mode ,
266- callback ) ;
265+ binding . open ( pathModule . _makeLong ( path ) ,
266+ stringToFlags ( flags ) ,
267+ mode ,
268+ callback ) ;
267269} ;
268270
269271fs . openSync = function ( path , flags , mode ) {
@@ -363,13 +365,14 @@ fs.writeSync = function(fd, buffer, offset, length, position) {
363365} ;
364366
365367fs . rename = function ( oldPath , newPath , callback ) {
366- binding . rename ( pathModule . _makeLong ( oldPath ) , pathModule . _makeLong ( newPath ) ,
367- callback || noop ) ;
368+ binding . rename ( pathModule . _makeLong ( oldPath ) ,
369+ pathModule . _makeLong ( newPath ) ,
370+ callback || noop ) ;
368371} ;
369372
370373fs . renameSync = function ( oldPath , newPath ) {
371374 return binding . rename ( pathModule . _makeLong ( oldPath ) ,
372- pathModule . _makeLong ( newPath ) ) ;
375+ pathModule . _makeLong ( newPath ) ) ;
373376} ;
374377
375378fs . truncate = function ( fd , len , callback ) {
@@ -407,12 +410,12 @@ fs.fsyncSync = function(fd) {
407410fs . mkdir = function ( path , mode , callback ) {
408411 if ( typeof mode === 'function' ) callback = mode ;
409412 binding . mkdir ( pathModule . _makeLong ( path ) , modeNum ( mode , 511 /*=0777*/ ) ,
410- callback || noop ) ;
413+ callback || noop ) ;
411414} ;
412415
413416fs . mkdirSync = function ( path , mode ) {
414417 return binding . mkdir ( pathModule . _makeLong ( path ) ,
415- modeNum ( mode , 511 /*=0777*/ ) ) ;
418+ modeNum ( mode , 511 /*=0777*/ ) ) ;
416419} ;
417420
418421fs . sendfile = function ( outFd , inFd , inOffset , length , callback ) {
@@ -468,22 +471,23 @@ fs.symlink = function(destination, path, type_, callback) {
468471 var callback_ = arguments [ arguments . length - 1 ] ;
469472 callback = ( typeof ( callback_ ) == 'function' ? callback_ : null ) ;
470473 binding . symlink ( pathModule . _makeLong ( destination ) ,
471- pathModule . _makeLong ( path ) , type , callback ) ;
474+ pathModule . _makeLong ( path ) , type , callback ) ;
472475} ;
473476
474477fs . symlinkSync = function ( destination , path , type ) {
475478 return binding . symlink ( pathModule . _makeLong ( destination ) ,
476- pathModule . _makeLong ( path ) , type ) ;
479+ pathModule . _makeLong ( path ) , type ) ;
477480} ;
478481
479482fs . link = function ( srcpath , dstpath , callback ) {
480- binding . link ( pathModule . _makeLong ( srcpath ) , pathModule . _makeLong ( dstpath ) ,
481- callback || noop ) ;
483+ binding . link ( pathModule . _makeLong ( srcpath ) ,
484+ pathModule . _makeLong ( dstpath ) ,
485+ callback || noop ) ;
482486} ;
483487
484488fs . linkSync = function ( srcpath , dstpath ) {
485489 return binding . link ( pathModule . _makeLong ( srcpath ) ,
486- pathModule . _makeLong ( dstpath ) ) ;
490+ pathModule . _makeLong ( dstpath ) ) ;
487491} ;
488492
489493fs . unlink = function ( path , callback ) {
@@ -637,7 +641,10 @@ function writeAll(fd, buffer, offset, length, position, callback) {
637641 if ( written === length ) {
638642 fs . close ( fd , callback ) ;
639643 } else {
640- writeAll ( fd , buffer , offset + written , length - written , position + written , callback ) ;
644+ offset += written ;
645+ length -= written ;
646+ position += written ;
647+ writeAll ( fd , buffer , offset , length , position , callback ) ;
641648 }
642649 }
643650 } ) ;
@@ -1462,7 +1469,8 @@ function SyncWriteStream(fd) {
14621469 this . fd = fd ;
14631470 this . writable = true ;
14641471 this . readable = false ;
1465- } ;
1472+ }
1473+
14661474util . inherits ( SyncWriteStream , Stream ) ;
14671475
14681476
@@ -1481,7 +1489,7 @@ SyncWriteStream.prototype.write = function(data, arg1, arg2) {
14811489 } else if ( typeof arg1 === 'function' ) {
14821490 cb = arg1 ;
14831491 } else {
1484- throw new Error ( " bad arg" ) ;
1492+ throw new Error ( ' bad arg' ) ;
14851493 }
14861494 }
14871495
0 commit comments