GeezerVison is showing github.com — doc: clarify how fs.Dirent file types are determined · nodejs/node@89aba0c
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: doc/api/fs.md +7Lines changed: 7 additions & 0 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -7386,6 +7386,13 @@ Additionally, when [`fs.readdir()`][] or [`fs.readdirSync()`][] is called with |
7386 | 7386 | the `withFileTypes` option set to `true`, the resulting array is filled with |
7387 | 7387 | {fs.Dirent} objects, rather than strings or {Buffer}s. |
7388 | 7388 |
|
| 7389 | +When a directory is read, such as with [`fs.readdir()`][] or |
| 7390 | +[`fs.opendir()`][], the file type of each entry is the type reported by the |
| 7391 | +operating system and may depend on the file system; for example, some file |
| 7392 | +systems may report a type that differs from what [`fs.lstat()`][] returns. |
| 7393 | +Node.js calls [`fs.lstat()`][] on such an entry only when the reported type |
| 7394 | +is unknown. Use [`fs.lstat()`][] when an accurate file type is required. |
| 7395 | +
|
7389 | 7396 | #### `dirent.isBlockDevice()` |
7390 | 7397 |
|
7391 | 7398 | <!-- YAML |
|