mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-08-27 23:42:51 +02:00
CFileHelpers: add function getDirSize()
Origin commit data
------------------
Branch: ni/coolstream
Commit: 1b095e725e
Author: Thilo Graf <dbt@novatux.de>
Date: 2015-02-07 (Sat, 07 Feb 2015)
------------------
No further description and justification available within origin commit message!
------------------
This commit was generated by Migit
This commit is contained in:
@@ -722,6 +722,34 @@ bool CFileHelpers::removeDir(const char *Dir)
|
||||
return true;
|
||||
}
|
||||
|
||||
u_int64_t CFileHelpers::getDirSize(const char *dirname)
|
||||
{
|
||||
DIR *d;
|
||||
struct dirent *de;
|
||||
struct stat buf;
|
||||
int exists;
|
||||
u_int64_t total_size = 0;
|
||||
|
||||
d = opendir(dirname);
|
||||
if (d == NULL) {
|
||||
perror("prsize");
|
||||
return 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;
|
||||
}
|
||||
|
||||
static int hdd_open_dev(const char * fname)
|
||||
{
|
||||
FILE * fp;
|
||||
|
Reference in New Issue
Block a user