Is there a POSIX function that will give me the size of a directory (including all sub-folders), roughly equivalent to "du -s somepath
"?
相关问题
- Multiple sockets for clients to connect to
- Is shmid returned by shmget() unique across proces
- What is the best way to do a search in a large fil
- glDrawElements only draws half a quad
- How to access the camera from my Windows Phone 8 a
Simple example
Result in bytes:
There is no ready-made function, so you will have to make your own. You may look at the source code of the GNU implemenation of du as an example (see http://www.gnu.org/prep/ftp.html for a list of places to download from). It is in the
coreutils
package.The crucial Posix calls are probably
opendir
,readdir
,closedir
, andstat
.