I am bit confused with the different between stat fstat and lstat functions in node.js. Could someone help to understand what is the major difference btwn stat, fstat and lstat functions in node.js and When to use stat, fstat and lstat functions.
Asked
Active
Viewed 9,832 times
1 Answers
63
stat
follows symlinks. When given a path that is a symlink, it returns the stat of the target of the symlink.lstat
doesn't follow symlinks. When given a path that is a symlink it returns the stat of the symlink and not its target.fstat
takes a file descriptor rather than a path.

Dan D.
- 73,243
- 15
- 104
- 123
-
-
7They are a type of file that contain a path. Their target which is used instead when opening the file. They are created by the `ln` command or the `link(2)` function which is available in Node as `fs.link`. – Dan D. Sep 09 '15 at 11:58
-
8
-
@OmarAlshaker Sort of. Shortcuts in Windows are just files with a `.lnk` extension. Explorer knows how to read them, but most other software just sees them as a regular file (because they are). – Clonkex Oct 31 '22 at 02:06