diff options
author | Joyee Cheung <joyeec9h3@gmail.com> | 2018-04-07 17:01:06 +0800 |
---|---|---|
committer | Joyee Cheung <joyeec9h3@gmail.com> | 2018-06-07 22:05:23 +0800 |
commit | 1e7645c39ae5213a44267cff3d599264c2211f1a (patch) | |
tree | a000944a7267c0ad8b0dfe325d93f34f564844ed /lib/internal/fs/utils.js | |
parent | af2a1045631028dfad0dd5d3eb4c4866fdf55730 (diff) | |
download | android-node-v8-1e7645c39ae5213a44267cff3d599264c2211f1a.tar.gz android-node-v8-1e7645c39ae5213a44267cff3d599264c2211f1a.tar.bz2 android-node-v8-1e7645c39ae5213a44267cff3d599264c2211f1a.zip |
fs: support BigInt in fs.*stat and fs.watchFile
Add the `bigint: true` option to all the `fs.*stat` methods and
`fs.watchFile`.
PR-URL: https://github.com/nodejs/node/pull/20220
Fixes: https://github.com/nodejs/node/issues/12115
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Diffstat (limited to 'lib/internal/fs/utils.js')
-rw-r--r-- | lib/internal/fs/utils.js | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/lib/internal/fs/utils.js b/lib/internal/fs/utils.js index a8c64e2b04..7092bbcb63 100644 --- a/lib/internal/fs/utils.js +++ b/lib/internal/fs/utils.js @@ -114,7 +114,7 @@ function preprocessSymlinkDestination(path, type, linkPath) { } function dateFromNumeric(num) { - return new Date(num + 0.5); + return new Date(Number(num) + 0.5); } // Constructor for file stats. @@ -155,7 +155,15 @@ function Stats( } Stats.prototype._checkModeProperty = function(property) { - return ((this.mode & S_IFMT) === property); + if (isWindows && (property === S_IFIFO || property === S_IFBLK || + property === S_IFSOCK)) { + return false; // Some types are not available on Windows + } + if (typeof this.mode === 'bigint') { // eslint-disable-line valid-typeof + // eslint-disable-next-line no-undef + return (this.mode & BigInt(S_IFMT)) === BigInt(property); + } + return (this.mode & S_IFMT) === property; }; Stats.prototype.isDirectory = function() { @@ -189,9 +197,9 @@ Stats.prototype.isSocket = function() { function getStatsFromBinding(stats, offset = 0) { return new Stats(stats[0 + offset], stats[1 + offset], stats[2 + offset], stats[3 + offset], stats[4 + offset], stats[5 + offset], - stats[6 + offset] < 0 ? undefined : stats[6 + offset], + isWindows ? undefined : stats[6 + offset], // blksize stats[7 + offset], stats[8 + offset], - stats[9 + offset] < 0 ? undefined : stats[9 + offset], + isWindows ? undefined : stats[9 + offset], // blocks stats[10 + offset], stats[11 + offset], stats[12 + offset], stats[13 + offset]); } |