@ -521,7 +521,6 @@ function tryStatSync(fd, isUserFd) {
} finally {
} finally {
if ( threw && ! isUserFd ) fs . closeSync ( fd ) ;
if ( threw && ! isUserFd ) fs . closeSync ( fd ) ;
}
}
return ! threw ;
}
}
function tryCreateBuffer ( size , fd , isUserFd ) {
function tryCreateBuffer ( size , fd , isUserFd ) {
@ -553,10 +552,11 @@ fs.readFileSync = function(path, options) {
var isUserFd = isFd ( path ) ; // file descriptor ownership
var isUserFd = isFd ( path ) ; // file descriptor ownership
var fd = isUserFd ? path : fs . openSync ( path , options . flag || 'r' , 0o666 ) ;
var fd = isUserFd ? path : fs . openSync ( path , options . flag || 'r' , 0o666 ) ;
tryStatSync ( fd , isUserFd ) ;
// Use stats array directly to avoid creating an fs.Stats instance just for
// Use stats array directly to avoid creating an fs.Stats instance just for
// our internal use.
// our internal use.
var size ;
var size ;
if ( tryStatSync ( fd , isUserFd ) && ( statValues [ 1 /*mode*/ ] & S_IFMT ) === S_IFREG )
if ( ( statValues [ 1 /*mode*/ ] & S_IFMT ) === S_IFREG )
size = statValues [ 8 /*size*/ ] ;
size = statValues [ 8 /*size*/ ] ;
else
else
size = 0 ;
size = 0 ;
@ -1085,7 +1085,7 @@ if (constants.O_SYMLINK !== undefined) {
callback ( err ) ;
callback ( err ) ;
return ;
return ;
}
}
// p refer to return the chmod error, if one occurs,
// P refer to return the chmod error, if one occurs,
// but still try to close, and report closing errors if they occur.
// but still try to close, and report closing errors if they occur.
fs . fchmod ( fd , mode , function ( err ) {
fs . fchmod ( fd , mode , function ( err ) {
fs . close ( fd , function ( err2 ) {
fs . close ( fd , function ( err2 ) {
@ -1098,20 +1098,18 @@ if (constants.O_SYMLINK !== undefined) {
fs . lchmodSync = function ( path , mode ) {
fs . lchmodSync = function ( path , mode ) {
var fd = fs . openSync ( path , constants . O_WRONLY | constants . O_SYMLINK ) ;
var fd = fs . openSync ( path , constants . O_WRONLY | constants . O_SYMLINK ) ;
// p refer to return the chmod error, if one occurs,
// P refer to return the chmod error, if one occurs,
// but still try to close, and report closing errors if they occur.
// but still try to close, and report closing errors if they occur.
var err , err2 , ret ;
var ret ;
try {
try {
ret = fs . fchmodSync ( fd , mode ) ;
ret = fs . fchmodSync ( fd , mode ) ;
} catch ( er ) {
} catch ( err ) {
err = er ;
try {
}
fs . closeSync ( fd ) ;
try {
} catch ( ignore ) { }
fs . closeSync ( fd ) ;
throw err ;
} catch ( er ) {
err2 = er ;
}
}
if ( err || err2 ) throw ( err || err2 ) ;
fs . closeSync ( fd ) ;
return ret ;
return ret ;
} ;
} ;
}
}