aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortenox7 <as@tenoware.com>2018-07-02 23:54:04 -0700
committertenox7 <as@tenoware.com>2018-07-02 23:54:04 -0700
commit7aed223e6787c1179870aa1a9fe56ade0a7fe624 (patch)
tree38804123f4a235f74ecd3a489e19fc2a6f6d18c1
parentc26dd4faa2c2b7642c67bbe8a61ba5b1612ce0cf (diff)
downloadwfm-7aed223e6787c1179870aa1a9fe56ade0a7fe624.tar.gz
fixed recursive du for .??* folders
-rw-r--r--fileio.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/fileio.c b/fileio.c
index 18a0025..1ab1205 100644
--- a/fileio.c
+++ b/fileio.c
@@ -386,8 +386,6 @@ void move(void) {
//
// Recursive Dir Size
//
-// NOTE: will not count directories starting with . (dot)
-// so size of git repo will not be included
off_t du(char *pdir) {
DIR *dir;
struct dirent *direntry;
@@ -405,10 +403,17 @@ off_t du(char *pdir) {
while(direntry) {
snprintf(child, PHYS_DIRNAME_SIZE, "%s/%s", pdir, direntry->d_name);
if(lstat(child, &fileinfo)==0) {
- if(S_ISDIR(fileinfo.st_mode) && (direntry->d_name[0]!='.')) //TODO: count other ".files" except . & ..
- tot+=du(child);
- else
+ if(S_ISDIR(fileinfo.st_mode)) {
+ if(direntry->d_name[0]=='.' && direntry->d_name[1]=='\0')
+ ;
+ else if(direntry->d_name[0]=='.' && direntry->d_name[1]=='.' && direntry->d_name[2]=='\0')
+ ;
+ else
+ tot+=du(child);
+ }
+ else {
tot+=fileinfo.st_size;
+ }
}
direntry=readdir(dir);
}