Есть функция:
unsigned long int directorysize(DIR *d)
{
struct dirent *de;
struct stat buf;
int exists;
int total_size;
if (d == NULL)
{
perror("prsize");
exit(EXIT_FAILURE);
}
total_size = 0;
for (de = readdir(d); de != NULL; de = readdir(d))
{
exists = stat(de->d_name, &buf);
if (exists < 0)
fprintf(stderr, "Couldn't stat %s\n", de->d_name);
else
total_size += buf.st_size;
}
closedir(d);
return (total_size + (HIDE_VOLUME * 2));
}
Но она вычисляет лишь размер той папки, в которой мы находимся, как сделать так, чтобы она проверяла и другие папки (Знаю.. можно использовать рекурсию, но всё никак не могу найти, как проверять другие папки)..
man 3 opendir
.