Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int getDirSize(char* directory)
- {
- struct stat statbuf;
- DIR *source_dir;
- struct dirent *dentry;
- int size=0;
- char str[100];
- source_dir = opendir(directory);
- while(dentry = readdir(source_dir))
- {
- if(dentry->d_type == 4)
- {
- if(dentry->d_name[0]!='.')
- {
- strcpy(str, directory);
- strcat(str, "/");
- strcat(str, dentry->d_name);
- lstat(str,&statbuf);
- size+=statbuf.st_blocks * 512/args.size+getDirSize(str);
- //getDirSize(str);
- printf("size=%f\n",ceil(size));
- printf("%s\n",dentry->d_name);
- }
- }
- else
- {
- strcpy(str,directory);
- strcat(str,"/");
- strcat(str,dentry->d_name);
- lstat(str,&statbuf);
- size+=statbuf.st_blocks*512/args.size;
- printf("size=%f\n",ceil(size));
- printf("%s\n",dentry->d_name);
- }
- }
- return size;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement