How do I get the size of a directory in node.js without recursively going through all the children in a directory?
E.g.,
var fs = require('fs');
fs.statSync('path/to/dir');
Will return me an object like this,
{ dev: 16777220,
mode: 16877,
nlink: 6,
uid: 501,
gid: 20,
rdev: 0,
blksize: 4096,
ino: 62403939,
size: 204,
blocks: 0,
atime: Mon May 25 2015 20:54:53 GMT-0400 (EDT),
mtime: Mon May 25 2015 20:09:41 GMT-0400 (EDT),
ctime: Mon May 25 2015 20:09:41 GMT-0400 (EDT) }
But the size
property is not the size of the directory and it's children (aka the sum of the files inside of it).
Is there no way to get the size of a dir (w/the sizes of the files inside of it included) without recursively finding the sizes of the children (and then summing those up)?
I'm basically trying to do the equivalent of du -ksh my-directory
but if the given directory is really large (e.g /
) than it takes forever to recursively get the true dir size..