|
@ -196,81 +196,13 @@ function Stats( |
|
|
this.ino = ino; |
|
|
this.ino = ino; |
|
|
this.size = size; |
|
|
this.size = size; |
|
|
this.blocks = blocks; |
|
|
this.blocks = blocks; |
|
|
this._atim_msec = atim_msec; |
|
|
this.atime = new Date(atim_msec + 0.5); |
|
|
this._mtim_msec = mtim_msec; |
|
|
this.mtime = new Date(mtim_msec + 0.5); |
|
|
this._ctim_msec = ctim_msec; |
|
|
this.ctime = new Date(ctim_msec + 0.5); |
|
|
this._birthtim_msec = birthtim_msec; |
|
|
this.birthtime = new Date(birthtim_msec + 0.5); |
|
|
} |
|
|
} |
|
|
fs.Stats = Stats; |
|
|
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
|
|
|
|
|
|
// + 0.5 is added to the Dates to protect values from being rounded down
|
|
|
|
|
|
// Ref: https://github.com/nodejs/node/pull/12607
|
|
|
|
|
|
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) { |
|
|
Stats.prototype._checkModeProperty = function(property) { |
|
|
return ((this.mode & S_IFMT) === property); |
|
|
return ((this.mode & S_IFMT) === property); |
|
|
}; |
|
|
}; |
|
|