Yes. There no readily available standard function that does this in one go. There may be some non-standard tools-library that provides this out there, but I haven't herad of any.
Using standard libary functions, you'll indeed need to roll your own, recursing into the subdirs, stat()-ing all files and add them all up.
Beware of hard links: do you want to double-count them? Probably not. The GNU "du" utility prevents double-counting hardlinks by storing and checking all visited inodes in a hash table.
If you intent to GPL your program, you could have a look at the sources of "du", or just copy parts of it right away (crediting GNU properly). You can find "du" in GNU's coreutils package.
Last edited by Hko; 04-21-2005 at 07:39 AM.