Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int getBlockSize(char* directory) {
- int size = 0;
- DIR *d;
- struct dirent *dir;
- struct stat fileStat;
- d = opendir(directory);
- if (d) {
- while ((dir = readdir(d)) != NULL) {
- if (dir->d_name[0] != '.') { // Ignore hidden files
- // Create the path to stat
- char info_path[PATH_MAX + 1];
- strcpy(info_path, directory);
- if (directory[strlen(directory) - 1] != '/')
- strcat(info_path, "/");
- strcat(info_path, dir->d_name);
- stat(info_path, &fileStat);
- size += fileStat.st_blocks;
- }
- }
- }
- return size;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement