@ -196,13 +196,79 @@ function Stats(
this . ino = ino ;
this . size = size ;
this . blocks = blocks ;
this . atime = new Date ( atim_msec ) ;
this . mtime = new Date ( mtim_msec ) ;
this . ctime = new Date ( ctim_msec ) ;
this . birthtime = new Date ( birthtim_msec ) ;
this . _ atim_msec = atim_msec ;
this . _ mtim_msec = mtim_msec ;
this . _ ctim_msec = ctim_msec ;
this . _ birthtim_msec = birthtim_msec ;
}
fs . Stats = Stats ;
// defining the properties in this fashion (explicitly with no loop or factory)
// has been shown to be the most performant on V8 contemp.
// Ref: https://github.com/nodejs/node/pull/12818
Object . defineProperties ( Stats . prototype , {
atime : {
configurable : true ,
enumerable : true ,
get ( ) {
return this . _ atime !== undefined ?
this . _ atime :
( this . _ atime = new Date ( this . _ atim_msec + 0.5 ) ) ;
} ,
set ( value ) { return this . _ atime = value ; }
} ,
mtime : {
configurable : true ,
enumerable : true ,
get ( ) {
return this . _ mtime !== undefined ?
this . _ mtime :
( this . _ mtime = new Date ( this . _ mtim_msec + 0.5 ) ) ;
} ,
set ( value ) { return this . _ mtime = value ; }
} ,
ctime : {
configurable : true ,
enumerable : true ,
get ( ) {
return this . _ ctime !== undefined ?
this . _ ctime :
( this . _ ctime = new Date ( this . _ ctim_msec + 0.5 ) ) ;
} ,
set ( value ) { return this . _ ctime = value ; }
} ,
birthtime : {
configurable : true ,
enumerable : true ,
get ( ) {
return this . _ birthtime !== undefined ?
this . _ birthtime :
( this . _ birthtime = new Date ( this . _ birthtim_msec + 0.5 ) ) ;
} ,
set ( value ) { return this . _ birthtime = value ; }
} ,
} ) ;
Stats . prototype . toJSON = function toJSON ( ) {
return {
dev : this . dev ,
mode : this . mode ,
nlink : this . nlink ,
uid : this . uid ,
gid : this . gid ,
rdev : this . rdev ,
blksize : this . blksize ,
ino : this . ino ,
size : this . size ,
blocks : this . blocks ,
atime : this . atime ,
ctime : this . ctime ,
mtime : this . mtime ,
birthtime : this . birthtime
} ;
} ;
Stats . prototype . _ checkModeProperty = function ( property ) {
return ( ( this . mode & S_IFMT ) === property ) ;
} ;