fs: support BigInt in fs.*stat and fs.watchFile · nodejs/node@04e8f07
@@ -248,7 +248,7 @@ function readFileAfterOpen(err, fd) {
248248const req = new FSReqWrap();
249249req.oncomplete = readFileAfterStat;
250250req.context = context;
251-binding.fstat(fd, req);
251+binding.fstat(fd, false, req);
252252}
253253254254function readFileAfterStat(err, stats) {
@@ -307,7 +307,7 @@ function readFile(path, options, callback) {
307307308308function tryStatSync(fd, isUserFd) {
309309const ctx = {};
310-const stats = binding.fstat(fd, undefined, ctx);
310+const stats = binding.fstat(fd, false, undefined, ctx);
311311if (ctx.errno !== undefined && !isUserFd) {
312312fs.closeSync(fd);
313313throw errors.uvException(ctx);
@@ -760,55 +760,67 @@ function readdirSync(path, options) {
760760return result;
761761}
762762763-function fstat(fd, callback) {
763+function fstat(fd, options, callback) {
764+if (arguments.length < 3) {
765+callback = options;
766+options = {};
767+}
764768validateUint32(fd, 'fd');
765-const req = new FSReqWrap();
769+const req = new FSReqWrap(options.bigint);
766770req.oncomplete = makeStatsCallback(callback);
767-binding.fstat(fd, req);
771+binding.fstat(fd, options.bigint, req);
768772}
769773770-function lstat(path, callback) {
774+function lstat(path, options, callback) {
775+if (arguments.length < 3) {
776+callback = options;
777+options = {};
778+}
771779callback = makeStatsCallback(callback);
772780path = getPathFromURL(path);
773781validatePath(path);
774-const req = new FSReqWrap();
782+const req = new FSReqWrap(options.bigint);
775783req.oncomplete = callback;
776-binding.lstat(pathModule.toNamespacedPath(path), req);
784+binding.lstat(pathModule.toNamespacedPath(path), options.bigint, req);
777785}
778786779-function stat(path, callback) {
787+function stat(path, options, callback) {
788+if (arguments.length < 3) {
789+callback = options;
790+options = {};
791+}
780792callback = makeStatsCallback(callback);
781793path = getPathFromURL(path);
782794validatePath(path);
783-const req = new FSReqWrap();
795+const req = new FSReqWrap(options.bigint);
784796req.oncomplete = callback;
785-binding.stat(pathModule.toNamespacedPath(path), req);
797+binding.stat(pathModule.toNamespacedPath(path), options.bigint, req);
786798}
787799788-function fstatSync(fd) {
800+function fstatSync(fd, options = {}) {
789801validateUint32(fd, 'fd');
790802const ctx = { fd };
791-const stats = binding.fstat(fd, undefined, ctx);
803+const stats = binding.fstat(fd, options.bigint, undefined, ctx);
792804handleErrorFromBinding(ctx);
793805return getStatsFromBinding(stats);
794806}
795807796-function lstatSync(path) {
808+function lstatSync(path, options = {}) {
797809path = getPathFromURL(path);
798810validatePath(path);
799811const ctx = { path };
800812const stats = binding.lstat(pathModule.toNamespacedPath(path),
801-undefined, ctx);
813+options.bigint, undefined, ctx);
802814handleErrorFromBinding(ctx);
803815return getStatsFromBinding(stats);
804816}
805817806-function statSync(path) {
818+function statSync(path, options = {}) {
807819path = getPathFromURL(path);
808820validatePath(path);
809821const ctx = { path };
810822const stats = binding.stat(pathModule.toNamespacedPath(path),
811-undefined, ctx);
823+options.bigint, undefined, ctx);
812824handleErrorFromBinding(ctx);
813825return getStatsFromBinding(stats);
814826}
@@ -1264,7 +1276,7 @@ function watchFile(filename, options, listener) {
12641276if (stat === undefined) {
12651277if (!watchers)
12661278watchers = require('internal/fs/watchers');
1267-stat = new watchers.StatWatcher();
1279+stat = new watchers.StatWatcher(options.bigint);
12681280stat.start(filename, options.persistent, options.interval);
12691281statWatchers.set(filename, stat);
12701282}
@@ -1379,7 +1391,7 @@ function realpathSync(p, options) {
13791391// On windows, check that the root exists. On unix there is no need.
13801392if (isWindows && !knownHard[base]) {
13811393const ctx = { path: base };
1382-binding.lstat(pathModule.toNamespacedPath(base), undefined, ctx);
1394+binding.lstat(pathModule.toNamespacedPath(base), false, undefined, ctx);
13831395handleErrorFromBinding(ctx);
13841396knownHard[base] = true;
13851397}
@@ -1421,7 +1433,7 @@ function realpathSync(p, options) {
1421143314221434const baseLong = pathModule.toNamespacedPath(base);
14231435const ctx = { path: base };
1424-const stats = binding.lstat(baseLong, undefined, ctx);
1436+const stats = binding.lstat(baseLong, false, undefined, ctx);
14251437handleErrorFromBinding(ctx);
1426143814271439if (!isFileType(stats, S_IFLNK)) {
@@ -1444,7 +1456,7 @@ function realpathSync(p, options) {
14441456}
14451457if (linkTarget === null) {
14461458const ctx = { path: base };
1447-binding.stat(baseLong, undefined, ctx);
1459+binding.stat(baseLong, false, undefined, ctx);
14481460handleErrorFromBinding(ctx);
14491461linkTarget = binding.readlink(baseLong, undefined, undefined, ctx);
14501462handleErrorFromBinding(ctx);
@@ -1465,7 +1477,7 @@ function realpathSync(p, options) {
14651477// On windows, check that the root exists. On unix there is no need.
14661478if (isWindows && !knownHard[base]) {
14671479const ctx = { path: base };
1468-binding.lstat(pathModule.toNamespacedPath(base), undefined, ctx);
1480+binding.lstat(pathModule.toNamespacedPath(base), false, undefined, ctx);
14691481handleErrorFromBinding(ctx);
14701482knownHard[base] = true;
14711483}