Posted inc programing
Counting Directory Size Recursively Using C Part 2
Even there’s an easier way calculating directory size ftw syscall/API
NAME ftw, nftw - file tree walk DESCRIPTION ftw() walks through the directory tree that is located under the directory dirpath, and calls fn() once for each entry in the tree. By default, directories are handled before the files and subdirectories they contain (pre-order traversal). CONFORMING TO POSIX.1-2001, SVr4, SUSv1.
example code size.c