From 7aed223e6787c1179870aa1a9fe56ade0a7fe624 Mon Sep 17 00:00:00 2001 From: tenox7 Date: Mon, 2 Jul 2018 23:54:04 -0700 Subject: fixed recursive du for .??* folders --- fileio.c | 15 ++++++++++----- 1 file 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); } -- cgit v1.2.3