Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NodeJS File Statistics

Tags:

node.js

fs

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!

like image 688
Richeve Bebedor Avatar asked Aug 02 '12 22:08

Richeve Bebedor


People also ask

How do I check the size of a node js file?

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.

What is statSync?

statSync() method is used to synchronously return information about the given file path.

What is __ Dirname in node?

__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.

What is the use of method stat in File System API of node?

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.


1 Answers

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 number
  • mode : protection
  • nlink : number of hard links
  • uid : user ID of owner
  • gid : 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/O
  • blocks : number of blocks allocated
like image 114
Pero P. Avatar answered Oct 19 '22 03:10

Pero P.