I'm looking for C good practice. I need to obtain a directory size in a C code on Linux. Please be aware that I'm really new to C.
I guess there are several ways to do this. Simpler might be to use "du" with a system() function and get the output. Correct?
More complicated would be to use stat() function recursively on all files and sub-directories, which is I guess what "du" already does.
I'm asking because I like to have the best performances possible. The size will require to be recalculated several times in my program process and as quickly as possible.
I also thought on "importing" the source code of "du" into my project if that is even an option.
Any input on this matter please?