| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 129dccf commit 643545a
10 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1525,6 +1525,19 @@ changes: | |||
| 1525 | 1525 | * Returns: {Promise} Fulfills with the {fs.Stats} object for the | |
| 1526 | 1526 | given `path`. | |
| 1527 | 1527 | ||
| 1528 | + ### `fsPromises.statfs(path[, options])` | ||
| 1529 | + | ||
| 1530 | + <!-- YAML | ||
| 1531 | + added: REPLACEME | ||
| 1532 | + --> | ||
| 1533 | + | ||
| 1534 | + * `path` {string|Buffer|URL} | ||
| 1535 | + * `options` {Object} | ||
| 1536 | + * `bigint` {boolean} Whether the numeric values in the returned | ||
| 1537 | + {fs.StatFs} object should be `bigint`. **Default:** `false`. | ||
| 1538 | + * Returns: {Promise} Fulfills with the {fs.StatFs} object for the | ||
| 1539 | + given `path`. | ||
| 1540 | + | ||
| 1528 | 1541 | ### `fsPromises.symlink(target, path[, type])` | |
| 1529 | 1542 | ||
| 1530 | 1543 | <!-- YAML | |
@@ -4082,6 +4095,26 @@ Stats { | |||
| 4082 | 4095 | } | |
| 4083 | 4096 | ``` | |
| 4084 | 4097 | ||
| 4098 | + ### `fs.statfs(path[, options], callback)` | ||
| 4099 | + | ||
| 4100 | + <!-- YAML | ||
| 4101 | + added: REPLACEME | ||
| 4102 | + --> | ||
| 4103 | + | ||
| 4104 | + * `path` {string|Buffer|URL} | ||
| 4105 | + * `options` {Object} | ||
| 4106 | + * `bigint` {boolean} Whether the numeric values in the returned | ||
| 4107 | + {fs.StatFs} object should be `bigint`. **Default:** `false`. | ||
| 4108 | + * `callback` {Function} | ||
| 4109 | + * `err` {Error} | ||
| 4110 | + * `stats` {fs.StatFs} | ||
| 4111 | + | ||
| 4112 | + Asynchronous statfs(2). Returns information about the mounted file system which | ||
| 4113 | + contains `path`. The callback gets two arguments `(err, stats)` where `stats` | ||
| 4114 | + is an {fs.StatFs} object. | ||
| 4115 | + | ||
| 4116 | + In case of an error, the `err.code` will be one of [Common System Errors][]. | ||
| 4117 | + | ||
| 4085 | 4118 | ### `fs.symlink(target, path[, type], callback)` | |
| 4086 | 4119 | ||
| 4087 | 4120 | <!-- YAML | |
@@ -5822,6 +5855,23 @@ changes: | |||
| 5822 | 5855 | ||
| 5823 | 5856 | Retrieves the {fs.Stats} for the path. | |
| 5824 | 5857 | ||
| 5858 | + ### `fs.statfsSync(path[, options])` | ||
| 5859 | + | ||
| 5860 | + <!-- YAML | ||
| 5861 | + added: REPLACEME | ||
| 5862 | + --> | ||
| 5863 | + | ||
| 5864 | + * `path` {string|Buffer|URL} | ||
| 5865 | + * `options` {Object} | ||
| 5866 | + * `bigint` {boolean} Whether the numeric values in the returned | ||
| 5867 | + {fs.StatFs} object should be `bigint`. **Default:** `false`. | ||
| 5868 | + * Returns: {fs.StatFs} | ||
| 5869 | + | ||
| 5870 | + Synchronous statfs(2). Returns information about the mounted file system which | ||
| 5871 | + contains `path`. | ||
| 5872 | + | ||
| 5873 | + In case of an error, the `err.code` will be one of [Common System Errors][]. | ||
| 5874 | + | ||
| 5825 | 5875 | ### `fs.symlinkSync(target, path[, type])` | |
| 5826 | 5876 | ||
| 5827 | 5877 | <!-- YAML | |
@@ -6908,6 +6958,114 @@ The times in the stat object have the following semantics: | |||
| 6908 | 6958 | Prior to Node.js 0.12, the `ctime` held the `birthtime` on Windows systems. As | |
| 6909 | 6959 | of 0.12, `ctime` is not "creation time", and on Unix systems, it never was. | |
| 6910 | 6960 | ||
| 6961 | + ### Class: `fs.StatFs` | ||
| 6962 | + | ||
| 6963 | + <!-- YAML | ||
| 6964 | + added: REPLACEME | ||
| 6965 | + --> | ||
| 6966 | + | ||
| 6967 | + Provides information about a mounted file system. | ||
| 6968 | + | ||
| 6969 | + Objects returned from [`fs.statfs()`][] and its synchronous counterpart are of | ||
| 6970 | + this type. If `bigint` in the `options` passed to those methods is `true`, the | ||
| 6971 | + numeric values will be `bigint` instead of `number`. | ||
| 6972 | + | ||
| 6973 | + ```console | ||
| 6974 | + StatFs { | ||
| 6975 | + type: 1397114950, | ||
| 6976 | + bsize: 4096, | ||
| 6977 | + blocks: 121938943, | ||
| 6978 | + bfree: 61058895, | ||
| 6979 | + bavail: 61058895, | ||
| 6980 | + files: 999, | ||
| 6981 | + ffree: 1000000 | ||
| 6982 | + } | ||
| 6983 | + ``` | ||
| 6984 | + | ||
| 6985 | + `bigint` version: | ||
| 6986 | + | ||
| 6987 | + ```console | ||
| 6988 | + StatFs { | ||
| 6989 | + type: 1397114950n, | ||
| 6990 | + bsize: 4096n, | ||
| 6991 | + blocks: 121938943n, | ||
| 6992 | + bfree: 61058895n, | ||
| 6993 | + bavail: 61058895n, | ||
| 6994 | + files: 999n, | ||
| 6995 | + ffree: 1000000n | ||
| 6996 | + } | ||
| 6997 | + ``` | ||
| 6998 | + | ||
| 6999 | + #### `statfs.bavail` | ||
| 7000 | + | ||
| 7001 | + <!-- YAML | ||
| 7002 | + added: REPLACEME | ||
| 7003 | + --> | ||
| 7004 | + | ||
| 7005 | + * {number|bigint} | ||
| 7006 | + | ||
| 7007 | + Free blocks available to unprivileged users. | ||
| 7008 | + | ||
| 7009 | + #### `statfs.bfree` | ||
| 7010 | + | ||
| 7011 | + <!-- YAML | ||
| 7012 | + added: REPLACEME | ||
| 7013 | + --> | ||
| 7014 | + | ||
| 7015 | + * {number|bigint} | ||
| 7016 | + | ||
| 7017 | + Free blocks in file system. | ||
| 7018 | + | ||
| 7019 | + #### `statfs.blocks` | ||
| 7020 | + | ||
| 7021 | + <!-- YAML | ||
| 7022 | + added: REPLACEME | ||
| 7023 | + --> | ||
| 7024 | + | ||
| 7025 | + * {number|bigint} | ||
| 7026 | + | ||
| 7027 | + Total data blocks in file system. | ||
| 7028 | + | ||
| 7029 | + #### `statfs.bsize` | ||
| 7030 | + | ||
| 7031 | + <!-- YAML | ||
| 7032 | + added: REPLACEME | ||
| 7033 | + --> | ||
| 7034 | + | ||
| 7035 | + * {number|bigint} | ||
| 7036 | + | ||
| 7037 | + Optimal transfer block size. | ||
| 7038 | + | ||
| 7039 | + #### `statfs.ffree` | ||
| 7040 | + | ||
| 7041 | + <!-- YAML | ||
| 7042 | + added: REPLACEME | ||
| 7043 | + --> | ||
| 7044 | + | ||
| 7045 | + * {number|bigint} | ||
| 7046 | + | ||
| 7047 | + Free file nodes in file system. | ||
| 7048 | + | ||
| 7049 | + #### `statfs.files` | ||
| 7050 | + | ||
| 7051 | + <!-- YAML | ||
| 7052 | + added: REPLACEME | ||
| 7053 | + --> | ||
| 7054 | + | ||
| 7055 | + * {number|bigint} | ||
| 7056 | + | ||
| 7057 | + Total file nodes in file system. | ||
| 7058 | + | ||
| 7059 | + #### `statfs.type` | ||
| 7060 | + | ||
| 7061 | + <!-- YAML | ||
| 7062 | + added: REPLACEME | ||
| 7063 | + --> | ||
| 7064 | + | ||
| 7065 | + * {number|bigint} | ||
| 7066 | + | ||
| 7067 | + Type of file system. | ||
| 7068 | + | ||
| 6911 | 7069 | ### Class: `fs.WriteStream` | |
| 6912 | 7070 | ||
| 6913 | 7071 | <!-- YAML | |
@@ -7751,6 +7909,7 @@ the file contents. | |||
| 7751 | 7909 | [`fs.rmSync()`]: #fsrmsyncpath-options | |
| 7752 | 7910 | [`fs.rmdir()`]: #fsrmdirpath-options-callback | |
| 7753 | 7911 | [`fs.stat()`]: #fsstatpath-options-callback | |
| 7912 | + [`fs.statfs()`]: #fsstatfspath-options-callback | ||
| 7754 | 7913 | [`fs.symlink()`]: #fssymlinktarget-path-type-callback | |
| 7755 | 7914 | [`fs.utimes()`]: #fsutimespath-atime-mtime-callback | |
| 7756 | 7915 | [`fs.watch()`]: #fswatchfilename-options-listener | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -104,6 +104,7 @@ const { | |||
| 104 | 104 | nullCheck, | |
| 105 | 105 | preprocessSymlinkDestination, | |
| 106 | 106 | Stats, | |
| 107 | + getStatFsFromBinding, | ||
| 107 | 108 | getStatsFromBinding, | |
| 108 | 109 | realpathCacheKey, | |
| 109 | 110 | stringToFlags, | |
@@ -1523,6 +1524,24 @@ function stat(path, options = { bigint: false }, callback) { | |||
| 1523 | 1524 | binding.stat(pathModule.toNamespacedPath(path), options.bigint, req); | |
| 1524 | 1525 | } | |
| 1525 | 1526 | ||
| 1527 | + function statfs(path, options = { bigint: false }, callback) { | ||
| 1528 | + if (typeof options === 'function') { | ||
| 1529 | + callback = options; | ||
| 1530 | + options = kEmptyObject; | ||
| 1531 | + } | ||
| 1532 | + callback = maybeCallback(callback); | ||
| 1533 | + path = getValidatedPath(path); | ||
| 1534 | + const req = new FSReqCallback(options.bigint); | ||
| 1535 | + req.oncomplete = (err, stats) => { | ||
| 1536 | + if (err) { | ||
| 1537 | + return callback(err); | ||
| 1538 | + } | ||
| 1539 | + | ||
| 1540 | + callback(err, getStatFsFromBinding(stats)); | ||
| 1541 | + }; | ||
| 1542 | + binding.statfs(pathModule.toNamespacedPath(path), options.bigint, req); | ||
| 1543 | + } | ||
| 1544 | + | ||
| 1526 | 1545 | function hasNoEntryError(ctx) { | |
| 1527 | 1546 | if (ctx.errno) { | |
| 1528 | 1547 | const uvErr = uvErrmapGet(ctx.errno); | |
@@ -1597,6 +1616,15 @@ function statSync(path, options = { bigint: false, throwIfNoEntry: true }) { | |||
| 1597 | 1616 | return getStatsFromBinding(stats); | |
| 1598 | 1617 | } | |
| 1599 | 1618 | ||
| 1619 | + function statfsSync(path, options = { bigint: false }) { | ||
| 1620 | + path = getValidatedPath(path); | ||
| 1621 | + const ctx = { path }; | ||
| 1622 | + const stats = binding.statfs(pathModule.toNamespacedPath(path), | ||
| 1623 | + options.bigint, undefined, ctx); | ||
| 1624 | + handleErrorFromBinding(ctx); | ||
| 1625 | + return getStatFsFromBinding(stats); | ||
| 1626 | + } | ||
| 1627 | + | ||
| 1600 | 1628 | /** | |
| 1601 | 1629 | * Reads the contents of a symbolic link | |
| 1602 | 1630 | * referred to by `path`. | |
@@ -3025,7 +3053,9 @@ module.exports = fs = { | |||
| 3025 | 3053 | rmdir, | |
| 3026 | 3054 | rmdirSync, | |
| 3027 | 3055 | stat, | |
| 3056 | + statfs, | ||
| 3028 | 3057 | statSync, | |
| 3058 | + statfsSync, | ||
| 3029 | 3059 | symlink, | |
| 3030 | 3060 | symlinkSync, | |
| 3031 | 3061 | truncate, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -52,6 +52,7 @@ const { | |||
| 52 | 52 | emitRecursiveRmdirWarning, | |
| 53 | 53 | getDirents, | |
| 54 | 54 | getOptions, | |
| 55 | + getStatFsFromBinding, | ||
| 55 | 56 | getStatsFromBinding, | |
| 56 | 57 | getValidatedPath, | |
| 57 | 58 | getValidMode, | |
@@ -767,6 +768,13 @@ async function stat(path, options = { bigint: false }) { | |||
| 767 | 768 | return getStatsFromBinding(result); | |
| 768 | 769 | } | |
| 769 | 770 | ||
| 771 | + async function statfs(path, options = { bigint: false }) { | ||
| 772 | + path = getValidatedPath(path); | ||
| 773 | + const result = await binding.statfs(pathModule.toNamespacedPath(path), | ||
| 774 | + options.bigint, kUsePromises); | ||
| 775 | + return getStatFsFromBinding(result); | ||
| 776 | + } | ||
| 777 | + | ||
| 770 | 778 | async function link(existingPath, newPath) { | |
| 771 | 779 | existingPath = getValidatedPath(existingPath, 'existingPath'); | |
| 772 | 780 | newPath = getValidatedPath(newPath, 'newPath'); | |
@@ -919,6 +927,7 @@ module.exports = { | |||
| 919 | 927 | symlink, | |
| 920 | 928 | lstat, | |
| 921 | 929 | stat, | |
| 930 | + statfs, | ||
| 922 | 931 | link, | |
| 923 | 932 | unlink, | |
| 924 | 933 | chmod, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -557,6 +557,24 @@ function getStatsFromBinding(stats, offset = 0) { | |||
| 557 | 557 | ); | |
| 558 | 558 | } | |
| 559 | 559 | ||
| 560 | + class StatFs { | ||
| 561 | + constructor(type, bsize, blocks, bfree, bavail, files, ffree) { | ||
| 562 | + this.type = type; | ||
| 563 | + this.bsize = bsize; | ||
| 564 | + this.blocks = blocks; | ||
| 565 | + this.bfree = bfree; | ||
| 566 | + this.bavail = bavail; | ||
| 567 | + this.files = files; | ||
| 568 | + this.ffree = ffree; | ||
| 569 | + } | ||
| 570 | + } | ||
| 571 | + | ||
| 572 | + function getStatFsFromBinding(stats) { | ||
| 573 | + return new StatFs( | ||
| 574 | + stats[0], stats[1], stats[2], stats[3], stats[4], stats[5], stats[6] | ||
| 575 | + ); | ||
| 576 | + } | ||
| 577 | + | ||
| 560 | 578 | function stringToFlags(flags, name = 'flags') { | |
| 561 | 579 | if (typeof flags === 'number') { | |
| 562 | 580 | validateInt32(flags, name); | |
@@ -934,6 +952,7 @@ module.exports = { | |||
| 934 | 952 | nullCheck, | |
| 935 | 953 | preprocessSymlinkDestination, | |
| 936 | 954 | realpathCacheKey: Symbol('realpathCacheKey'), | |
| 955 | + getStatFsFromBinding, | ||
| 937 | 956 | getStatsFromBinding, | |
| 938 | 957 | stringToFlags, | |
| 939 | 958 | stringToSymlinkType, | |
| Back | FazBrowse Home | New Git URL |
0 commit comments