diff options
Diffstat (limited to 'c/tree/main.c')
-rw-r--r-- | c/tree/main.c | 38 |
1 files changed, 13 insertions, 25 deletions
diff --git a/c/tree/main.c b/c/tree/main.c index 86d2c30..b4b3374 100644 --- a/c/tree/main.c +++ b/c/tree/main.c @@ -6,32 +6,18 @@ #include "tree.h" -bool checkdir(const char * dir) +void printChild(const regfile * head) { - struct stat st; - stat(dir,&st); - - return S_ISDIR(st.st_mode); -} - -void printChild(const char * cur) -{ - DIR * d = opendir(cur); - - struct dirent * dir; - - if (!d) - error("Failed to open directory"); - - while ((dir = readdir(d))) { - //if (dir->d_name[1] == '.' || strcmp(".",dir->d_name) == 0) - if (dir->d_name[1] == '.' || dir->d_name[0] == '.' && dir->d_name[1] == '\0') - continue; - printf("%s\n", dir->d_name); - - if (checkdir(dir->d_name) == true) { - printChild(dir->d_name); - } + regfile * scan = head->next; + + while (scan != NULL) { + printf("%s\tlevel: %d\tname length: %u\tfile or dir: ",scan->node->text, + scan->node->level, scan->node->len); + if (scan->node->fod) + printf("dir\n"); + else + printf("file\n"); + scan = scan->next; } } @@ -41,6 +27,8 @@ int main() getfile(&head,"."); + printChild(&head); + empty(&head); return 0; |