I don't know if this is a valid question but is there a documentation out there describing each property from the result of fs.stat()
in nodejs. Because I am trying to find the meaning of each of those properties but no luck.
Thanks!
To get the size of a file in Node. js, you can use the stat() method provided by the built-in fs module. This method works asynchronously and lists the statistics of a file at the given path. The size of the file is returned in bytes.
statSync() method is used to synchronously return information about the given file path.
__dirname: It is a local variable that returns the directory name of the current module. It returns the folder path of the current JavaScript file.
stat() method is used to return information about the given file or directory. It returns an fs. Stat object which has several properties and methods to get details about the file or directory.
Comments in the node_file.cc source that builds the stat
object (BuildsStatsObject
function) may conveniently help you out with this. In summary for reference:
dev
: ID of device containing file ino
: inode numbermode
: protectionnlink
: number of hard linksuid
: user ID of ownergid
: group ID of owner rdev
: device ID (if special file) size
: total size, in bytes atime
- time of last access mtime
- time of last modification ctime
- time of last status change and if POSIX
blksize
: blocksize for filesystem I/Oblocks
: number of blocks allocated If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With