aboutsummaryrefslogtreecommitdiff
path: root/lib/internal/fs/utils.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/internal/fs/utils.js')
-rw-r--r--lib/internal/fs/utils.js16
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]);
}