-
Notifications
You must be signed in to change notification settings - Fork 30.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
doc: update documentation in fs.StatsFs #54309
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -7509,6 +7509,19 @@ added: | |||||
|
||||||
Free blocks available to unprivileged users. | ||||||
|
||||||
**Example:** | ||||||
```javascript | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you please verify all the changes? |
||||||
import { statfs } from "fs/promises"; | ||||||
|
||||||
async function getAvailableSpace(path) { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For the sake of simplicity, isn't it better to use top level await instead of an async function? |
||||||
const stats = await statfs(path); | ||||||
const availableSpace = stats.bsize * stats.bavail; // available space in bytes | ||||||
console.log(`Available space: ${availableSpace} bytes`); | ||||||
} | ||||||
|
||||||
getAvailableSpace("/tmp"); | ||||||
``` | ||||||
|
||||||
#### `statfs.bfree` | ||||||
|
||||||
<!-- YAML | ||||||
|
@@ -7521,6 +7534,19 @@ added: | |||||
|
||||||
Free blocks in file system. | ||||||
|
||||||
**Example:** | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
```javascript | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
import { statfs } from "fs/promises"; | ||||||
|
||||||
async function getFreeSpace(path) { | ||||||
const stats = await statfs(path); | ||||||
const freeSpace = stats.bsize * stats.bfree; // free space in bytes | ||||||
console.log(`Free space: ${freeSpace} bytes`); | ||||||
} | ||||||
|
||||||
getFreeSpace("/tmp"); | ||||||
``` | ||||||
|
||||||
#### `statfs.blocks` | ||||||
|
||||||
<!-- YAML | ||||||
|
@@ -7533,6 +7559,18 @@ added: | |||||
|
||||||
Total data blocks in file system. | ||||||
|
||||||
**Example:** | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you please verify the changes? |
||||||
```javascript | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
import { statfs } from "fs/promises"; | ||||||
|
||||||
async function getTotalBlocks(path) { | ||||||
const stats = await statfs(path); | ||||||
console.log(`Total blocks: ${stats.blocks}`); | ||||||
} | ||||||
|
||||||
getTotalBlocks("/tmp"); | ||||||
``` | ||||||
|
||||||
#### `statfs.bsize` | ||||||
|
||||||
<!-- YAML | ||||||
|
@@ -7543,7 +7581,7 @@ added: | |||||
|
||||||
* {number|bigint} | ||||||
|
||||||
Optimal transfer block size. | ||||||
Optimal transfer block size in bytes. | ||||||
|
||||||
#### `statfs.ffree` | ||||||
|
||||||
|
@@ -7569,6 +7607,17 @@ added: | |||||
|
||||||
Total file nodes in file system. | ||||||
|
||||||
```javascript | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
import { statfs } from "fs/promises"; | ||||||
|
||||||
async function getTotalFiles(path) { | ||||||
const stats = await statfs(path); | ||||||
console.log(`Total file nodes: ${stats.files}`); | ||||||
} | ||||||
|
||||||
getTotalFiles("/tmp"); | ||||||
``` | ||||||
|
||||||
#### `statfs.type` | ||||||
|
||||||
<!-- YAML | ||||||
|
@@ -7579,7 +7628,8 @@ added: | |||||
|
||||||
* {number|bigint} | ||||||
|
||||||
Type of file system. | ||||||
Type of file system. | ||||||
This numeric value represents the file system type (e.g., EXT4, NTFS, etc.). The specific value can be interpreted by referring to platform-specific documentation or using a lookup table. | ||||||
|
||||||
### Class: `fs.WriteStream` | ||||||
|
||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.