| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -248,7 +248,7 @@ function readFileAfterOpen(err, fd) { | |||
| 248 | 248 | const req = new FSReqWrap(); | |
| 249 | 249 | req.oncomplete = readFileAfterStat; | |
| 250 | 250 | req.context = context; | |
| 251 | - binding.fstat(fd, req); | ||
| 251 | + binding.fstat(fd, false, req); | ||
| 252 | 252 | } | |
| 253 | 253 | ||
| 254 | 254 | function readFileAfterStat(err, stats) { | |
@@ -307,7 +307,7 @@ function readFile(path, options, callback) { | |||
| 307 | 307 | ||
| 308 | 308 | function tryStatSync(fd, isUserFd) { | |
| 309 | 309 | const ctx = {}; | |
| 310 | - const stats = binding.fstat(fd, undefined, ctx); | ||
| 310 | + const stats = binding.fstat(fd, false, undefined, ctx); | ||
| 311 | 311 | if (ctx.errno !== undefined && !isUserFd) { | |
| 312 | 312 | fs.closeSync(fd); | |
| 313 | 313 | throw errors.uvException(ctx); | |
@@ -760,55 +760,67 @@ function readdirSync(path, options) { | |||
| 760 | 760 | return result; | |
| 761 | 761 | } | |
| 762 | 762 | ||
| 763 | - function fstat(fd, callback) { | ||
| 763 | + function fstat(fd, options, callback) { | ||
| 764 | + if (arguments.length < 3) { | ||
| 765 | + callback = options; | ||
| 766 | + options = {}; | ||
| 767 | + } | ||
| 764 | 768 | validateUint32(fd, 'fd'); | |
| 765 | - const req = new FSReqWrap(); | ||
| 769 | + const req = new FSReqWrap(options.bigint); | ||
| 766 | 770 | req.oncomplete = makeStatsCallback(callback); | |
| 767 | - binding.fstat(fd, req); | ||
| 771 | + binding.fstat(fd, options.bigint, req); | ||
| 768 | 772 | } | |
| 769 | 773 | ||
| 770 | - function lstat(path, callback) { | ||
| 774 | + function lstat(path, options, callback) { | ||
| 775 | + if (arguments.length < 3) { | ||
| 776 | + callback = options; | ||
| 777 | + options = {}; | ||
| 778 | + } | ||
| 771 | 779 | callback = makeStatsCallback(callback); | |
| 772 | 780 | path = getPathFromURL(path); | |
| 773 | 781 | validatePath(path); | |
| 774 | - const req = new FSReqWrap(); | ||
| 782 | + const req = new FSReqWrap(options.bigint); | ||
| 775 | 783 | req.oncomplete = callback; | |
| 776 | - binding.lstat(pathModule.toNamespacedPath(path), req); | ||
| 784 | + binding.lstat(pathModule.toNamespacedPath(path), options.bigint, req); | ||
| 777 | 785 | } | |
| 778 | 786 | ||
| 779 | - function stat(path, callback) { | ||
| 787 | + function stat(path, options, callback) { | ||
| 788 | + if (arguments.length < 3) { | ||
| 789 | + callback = options; | ||
| 790 | + options = {}; | ||
| 791 | + } | ||
| 780 | 792 | callback = makeStatsCallback(callback); | |
| 781 | 793 | path = getPathFromURL(path); | |
| 782 | 794 | validatePath(path); | |
| 783 | - const req = new FSReqWrap(); | ||
| 795 | + const req = new FSReqWrap(options.bigint); | ||
| 784 | 796 | req.oncomplete = callback; | |
| 785 | - binding.stat(pathModule.toNamespacedPath(path), req); | ||
| 797 | + binding.stat(pathModule.toNamespacedPath(path), options.bigint, req); | ||
| 786 | 798 | } | |
| 787 | 799 | ||
| 788 | - function fstatSync(fd) { | ||
| 800 | + function fstatSync(fd, options = {}) { | ||
| 789 | 801 | validateUint32(fd, 'fd'); | |
| 790 | 802 | const ctx = { fd }; | |
| 791 | - const stats = binding.fstat(fd, undefined, ctx); | ||
| 803 | + const stats = binding.fstat(fd, options.bigint, undefined, ctx); | ||
| 792 | 804 | handleErrorFromBinding(ctx); | |
| 793 | 805 | return getStatsFromBinding(stats); | |
| 794 | 806 | } | |
| 795 | 807 | ||
| 796 | - function lstatSync(path) { | ||
| 808 | + function lstatSync(path, options = {}) { | ||
| 797 | 809 | path = getPathFromURL(path); | |
| 798 | 810 | validatePath(path); | |
| 799 | 811 | const ctx = { path }; | |
| 800 | 812 | const stats = binding.lstat(pathModule.toNamespacedPath(path), | |
| 801 | - undefined, ctx); | ||
| 813 | + options.bigint, undefined, ctx); | ||
| 802 | 814 | handleErrorFromBinding(ctx); | |
| 803 | 815 | return getStatsFromBinding(stats); | |
| 804 | 816 | } | |
| 805 | 817 | ||
| 806 | - function statSync(path) { | ||
| 818 | + function statSync(path, options = {}) { | ||
| 807 | 819 | path = getPathFromURL(path); | |
| 808 | 820 | validatePath(path); | |
| 809 | 821 | const ctx = { path }; | |
| 810 | 822 | const stats = binding.stat(pathModule.toNamespacedPath(path), | |
| 811 | - undefined, ctx); | ||
| 823 | + options.bigint, undefined, ctx); | ||
| 812 | 824 | handleErrorFromBinding(ctx); | |
| 813 | 825 | return getStatsFromBinding(stats); | |
| 814 | 826 | } | |
@@ -1264,7 +1276,7 @@ function watchFile(filename, options, listener) { | |||
| 1264 | 1276 | if (stat === undefined) { | |
| 1265 | 1277 | if (!watchers) | |
| 1266 | 1278 | watchers = require('internal/fs/watchers'); | |
| 1267 | - stat = new watchers.StatWatcher(); | ||
| 1279 | + stat = new watchers.StatWatcher(options.bigint); | ||
| 1268 | 1280 | stat.start(filename, options.persistent, options.interval); | |
| 1269 | 1281 | statWatchers.set(filename, stat); | |
| 1270 | 1282 | } | |
@@ -1379,7 +1391,7 @@ function realpathSync(p, options) { | |||
| 1379 | 1391 | // On windows, check that the root exists. On unix there is no need. | |
| 1380 | 1392 | if (isWindows && !knownHard[base]) { | |
| 1381 | 1393 | const ctx = { path: base }; | |
| 1382 | - binding.lstat(pathModule.toNamespacedPath(base), undefined, ctx); | ||
| 1394 | + binding.lstat(pathModule.toNamespacedPath(base), false, undefined, ctx); | ||
| 1383 | 1395 | handleErrorFromBinding(ctx); | |
| 1384 | 1396 | knownHard[base] = true; | |
| 1385 | 1397 | } | |
@@ -1421,7 +1433,7 @@ function realpathSync(p, options) { | |||
| 1421 | 1433 | ||
| 1422 | 1434 | const baseLong = pathModule.toNamespacedPath(base); | |
| 1423 | 1435 | const ctx = { path: base }; | |
| 1424 | - const stats = binding.lstat(baseLong, undefined, ctx); | ||
| 1436 | + const stats = binding.lstat(baseLong, false, undefined, ctx); | ||
| 1425 | 1437 | handleErrorFromBinding(ctx); | |
| 1426 | 1438 | ||
| 1427 | 1439 | if (!isFileType(stats, S_IFLNK)) { | |
@@ -1444,7 +1456,7 @@ function realpathSync(p, options) { | |||
| 1444 | 1456 | } | |
| 1445 | 1457 | if (linkTarget === null) { | |
| 1446 | 1458 | const ctx = { path: base }; | |
| 1447 | - binding.stat(baseLong, undefined, ctx); | ||
| 1459 | + binding.stat(baseLong, false, undefined, ctx); | ||
| 1448 | 1460 | handleErrorFromBinding(ctx); | |
| 1449 | 1461 | linkTarget = binding.readlink(baseLong, undefined, undefined, ctx); | |
| 1450 | 1462 | handleErrorFromBinding(ctx); | |
@@ -1465,7 +1477,7 @@ function realpathSync(p, options) { | |||
| 1465 | 1477 | // On windows, check that the root exists. On unix there is no need. | |
| 1466 | 1478 | if (isWindows && !knownHard[base]) { | |
| 1467 | 1479 | const ctx = { path: base }; | |
| 1468 | - binding.lstat(pathModule.toNamespacedPath(base), undefined, ctx); | ||
| 1480 | + binding.lstat(pathModule.toNamespacedPath(base), false, undefined, ctx); | ||
| 1469 | 1481 | handleErrorFromBinding(ctx); | |
| 1470 | 1482 | knownHard[base] = true; | |
| 1471 | 1483 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -81,8 +81,8 @@ class FileHandle { | |||
| 81 | 81 | return readFile(this, options); | |
| 82 | 82 | } | |
| 83 | 83 | ||
| 84 | - stat() { | ||
| 85 | - return fstat(this); | ||
| 84 | + stat(options) { | ||
| 85 | + return fstat(this, options); | ||
| 86 | 86 | } | |
| 87 | 87 | ||
| 88 | 88 | truncate(len = 0) { | |
@@ -106,7 +106,6 @@ class FileHandle { | |||
| 106 | 106 | } | |
| 107 | 107 | } | |
| 108 | 108 | ||
| 109 | - | ||
| 110 | 109 | function validateFileHandle(handle) { | |
| 111 | 110 | if (!(handle instanceof FileHandle)) | |
| 112 | 111 | throw new ERR_INVALID_ARG_TYPE('filehandle', 'FileHandle', handle); | |
@@ -127,7 +126,7 @@ async function writeFileHandle(filehandle, data, options) { | |||
| 127 | 126 | } | |
| 128 | 127 | ||
| 129 | 128 | async function readFileHandle(filehandle, options) { | |
| 130 | - const statFields = await binding.fstat(filehandle.fd, kUsePromises); | ||
| 129 | + const statFields = await binding.fstat(filehandle.fd, false, kUsePromises); | ||
| 131 | 130 | ||
| 132 | 131 | let size; | |
| 133 | 132 | if ((statFields[1/* mode */] & S_IFMT) === S_IFREG) { | |
@@ -318,25 +317,25 @@ async function symlink(target, path, type_) { | |||
| 318 | 317 | kUsePromises); | |
| 319 | 318 | } | |
| 320 | 319 | ||
| 321 | - async function fstat(handle) { | ||
| 320 | + async function fstat(handle, options = { bigint: false }) { | ||
| 322 | 321 | validateFileHandle(handle); | |
| 323 | - const result = await binding.fstat(handle.fd, kUsePromises); | ||
| 322 | + const result = await binding.fstat(handle.fd, options.bigint, kUsePromises); | ||
| 324 | 323 | return getStatsFromBinding(result); | |
| 325 | 324 | } | |
| 326 | 325 | ||
| 327 | - async function lstat(path) { | ||
| 326 | + async function lstat(path, options = { bigint: false }) { | ||
| 328 | 327 | path = getPathFromURL(path); | |
| 329 | 328 | validatePath(path); | |
| 330 | 329 | const result = await binding.lstat(pathModule.toNamespacedPath(path), | |
| 331 | - kUsePromises); | ||
| 330 | + options.bigint, kUsePromises); | ||
| 332 | 331 | return getStatsFromBinding(result); | |
| 333 | 332 | } | |
| 334 | 333 | ||
| 335 | - async function stat(path) { | ||
| 334 | + async function stat(path, options = { bigint: false }) { | ||
| 336 | 335 | path = getPathFromURL(path); | |
| 337 | 336 | validatePath(path); | |
| 338 | 337 | const result = await binding.stat(pathModule.toNamespacedPath(path), | |
| 339 | - kUsePromises); | ||
| 338 | + options.bigint, kUsePromises); | ||
| 340 | 339 | return getStatsFromBinding(result); | |
| 341 | 340 | } | |
| 342 | 341 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -114,7 +114,7 @@ function preprocessSymlinkDestination(path, type, linkPath) { | |||
| 114 | 114 | } | |
| 115 | 115 | ||
| 116 | 116 | function dateFromNumeric(num) { | |
| 117 | - return new Date(num + 0.5); | ||
| 117 | + return new Date(Number(num) + 0.5); | ||
| 118 | 118 | } | |
| 119 | 119 | ||
| 120 | 120 | // Constructor for file stats. | |
@@ -155,7 +155,15 @@ function Stats( | |||
| 155 | 155 | } | |
| 156 | 156 | ||
| 157 | 157 | Stats.prototype._checkModeProperty = function(property) { | |
| 158 | - return ((this.mode & S_IFMT) === property); | ||
| 158 | + if (isWindows && (property === S_IFIFO || property === S_IFBLK || | ||
| 159 | + property === S_IFSOCK)) { | ||
| 160 | + return false; // Some types are not available on Windows | ||
| 161 | + } | ||
| 162 | + if (typeof this.mode === 'bigint') { // eslint-disable-line valid-typeof | ||
| 163 | + // eslint-disable-next-line no-undef | ||
| 164 | + return (this.mode & BigInt(S_IFMT)) === BigInt(property); | ||
| 165 | + } | ||
| 166 | + return (this.mode & S_IFMT) === property; | ||
| 159 | 167 | }; | |
| 160 | 168 | ||
| 161 | 169 | Stats.prototype.isDirectory = function() { | |
@@ -189,9 +197,9 @@ Stats.prototype.isSocket = function() { | |||
| 189 | 197 | function getStatsFromBinding(stats, offset = 0) { | |
| 190 | 198 | return new Stats(stats[0 + offset], stats[1 + offset], stats[2 + offset], | |
| 191 | 199 | stats[3 + offset], stats[4 + offset], stats[5 + offset], | |
| 192 | - stats[6 + offset] < 0 ? undefined : stats[6 + offset], | ||
| 200 | + isWindows ? undefined : stats[6 + offset], // blksize | ||
| 193 | 201 | stats[7 + offset], stats[8 + offset], | |
| 194 | - stats[9 + offset] < 0 ? undefined : stats[9 + offset], | ||
| 202 | + isWindows ? undefined : stats[9 + offset], // blocks | ||
| 195 | 203 | stats[10 + offset], stats[11 + offset], | |
| 196 | 204 | stats[12 + offset], stats[13 + offset]); | |
| 197 | 205 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -21,10 +21,10 @@ function emitStop(self) { | |||
| 21 | 21 | self.emit('stop'); | |
| 22 | 22 | } | |
| 23 | 23 | ||
| 24 | - function StatWatcher() { | ||
| 24 | + function StatWatcher(bigint) { | ||
| 25 | 25 | EventEmitter.call(this); | |
| 26 | 26 | ||
| 27 | - this._handle = new _StatWatcher(); | ||
| 27 | + this._handle = new _StatWatcher(bigint); | ||
| 28 | 28 | ||
| 29 | 29 | // uv_fs_poll is a little more powerful than ev_stat but we curb it for | |
| 30 | 30 | // the sake of backwards compatibility | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -546,6 +546,11 @@ Environment::fs_stats_field_array() { | |||
| 546 | 546 | return &fs_stats_field_array_; | |
| 547 | 547 | } | |
| 548 | 548 | ||
| 549 | + inline AliasedBuffer<uint64_t, v8::BigUint64Array>* | ||
| 550 | + Environment::fs_stats_field_bigint_array() { | ||
| 551 | + return &fs_stats_field_bigint_array_; | ||
| 552 | + } | ||
| 553 | + | ||
| 549 | 554 | inline std::vector<std::unique_ptr<fs::FileHandleReadWrap>>& | |
| 550 | 555 | Environment::file_handle_read_wrap_freelist() { | |
| 551 | 556 | return file_handle_read_wrap_freelist_; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -116,6 +116,7 @@ Environment::Environment(IsolateData* isolate_data, | |||
| 116 | 116 | #endif | |
| 117 | 117 | http_parser_buffer_(nullptr), | |
| 118 | 118 | fs_stats_field_array_(isolate_, kFsStatsFieldsLength * 2), | |
| 119 | + fs_stats_field_bigint_array_(isolate_, kFsStatsFieldsLength * 2), | ||
| 119 | 120 | context_(context->GetIsolate(), context) { | |
| 120 | 121 | // We'll be creating new objects so make sure we've entered the context. | |
| 121 | 122 | v8::HandleScope handle_scope(isolate()); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -694,6 +694,8 @@ class Environment { | |||
| 694 | 694 | void set_debug_categories(const std::string& cats, bool enabled); | |
| 695 | 695 | ||
| 696 | 696 | inline AliasedBuffer<double, v8::Float64Array>* fs_stats_field_array(); | |
| 697 | + inline AliasedBuffer<uint64_t, v8::BigUint64Array>* | ||
| 698 | + fs_stats_field_bigint_array(); | ||
| 697 | 699 | ||
| 698 | 700 | // stat fields contains twice the number of entries because `fs.StatWatcher` | |
| 699 | 701 | // needs room to store data for *two* `fs.Stats` instances. | |
@@ -914,6 +916,7 @@ class Environment { | |||
| 914 | 916 | bool debug_enabled_[static_cast<int>(DebugCategory::CATEGORY_COUNT)] = {0}; | |
| 915 | 917 | ||
| 916 | 918 | AliasedBuffer<double, v8::Float64Array> fs_stats_field_array_; | |
| 919 | + AliasedBuffer<uint64_t, v8::BigUint64Array> fs_stats_field_bigint_array_; | ||
| 917 | 920 | ||
| 918 | 921 | std::vector<std::unique_ptr<fs::FileHandleReadWrap>> | |
| 919 | 922 | file_handle_read_wrap_freelist_; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments