8000
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 49c5339 commit c177a68Copy full SHA for c177a68
doc/api/fs.md
@@ -3020,6 +3020,76 @@ error raised if the file is not available.
3020
To check if a file exists without manipulating it afterwards, [`fs.access()`]
3021
is recommended.
3022
3023
+For example, given the following folder structure:
3024
+
3025
+```fundamental
3026
+- txtDir
3027
+-- file.txt
3028
+- app.js
3029
+```
3030
3031
+The next program will check for the stats of the given paths:
3032
3033
+```js
3034
+const fs = require('fs');
3035
3036
+const pathsToCheck = ['./txtDir', './txtDir/file.txt'];
3037
3038
+for (let i = 0; i < pathsToCheck.length; i++) {
3039
+ fs.stat(pathsToCheck[i], function(err, stats) {
3040
+ console.log(stats.isDirectory());
3041
+ console.log(stats);
3042
+ });
3043
+}
3044
3045
3046
+The resulting output will resemble:
3047
3048
+```console
3049
+true
3050
+Stats {
3051
+ dev: 16777220,
3052
+ mode: 16877,
3053
+ nlink: 3,
3054
+ uid: 501,
3055
+ gid: 20,
3056
+ rdev: 0,
3057
+ blksize: 4096,
3058
+ ino: 14214262,
3059
+ size: 96,
3060
+ blocks: 0,
3061
+ atimeMs: 1561174653071.963,
3062
+ mtimeMs: 1561174614583.3518,
3063
+ ctimeMs: 1561174626623.5366,
3064
+ birthtimeMs: 1561174126937.2893,
3065
+ atime: 2019-06-22T03:37:33.072Z,
3066
+ mtime: 2019-06-22T03:36:54.583Z,
3067
+ ctime: 2019-06-22T03:37:06.624Z,
3068
+ birthtime: 2019-06-22T03:28:46.937Z
3069
3070
+false
3071
3072
3073
+ mode: 33188,
3074
+ nlink: 1,
3075
3076
3077
3078
3079
+ ino: 14214074,
3080
+ size: 8,
3081
+ blocks: 8,
3082
+ atimeMs: 1561174616618.8555,
3083
+ mtimeMs: 1561174614584,
3084
+ ctimeMs: 1561174614583.8145,
3085
+ birthtimeMs: 1561174007710.7478,
3086
+ atime: 2019-06-22T03:36:56.619Z,
3087
+ mtime: 2019-06-22T03:36:54.584Z,
3088
+ ctime: 2019-06-22T03:36:54.584Z,
3089
+ birthtime: 2019-06-22T03:26:47.711Z
3090
3091
3092
3093
## fs.statSync(path[, options])
3094
<!-- YAML
3095
added: v0.1.21