diff options
author | tenox7 <as@tenoware.com> | 2018-07-02 23:54:04 -0700 |
---|---|---|
committer | tenox7 <as@tenoware.com> | 2018-07-02 23:54:04 -0700 |
commit | 7aed223e6787c1179870aa1a9fe56ade0a7fe624 (patch) | |
tree | 38804123f4a235f74ecd3a489e19fc2a6f6d18c1 | |
parent | c26dd4faa2c2b7642c67bbe8a61ba5b1612ce0cf (diff) | |
download | wfm-7aed223e6787c1179870aa1a9fe56ade0a7fe624.tar.gz |
fixed recursive du for .??* folders
-rw-r--r-- | fileio.c | 15 |
1 files changed, 10 insertions, 5 deletions
@@ -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); } |