diff options
author | garhve <git@garhve.com> | 2022-12-14 19:53:52 +0800 |
---|---|---|
committer | garhve <git@garhve.com> | 2022-12-14 19:53:52 +0800 |
commit | e654642d76e08a6a6b0517022eaeab29c5819c46 (patch) | |
tree | 7bc15617aab5993099d37448c5564386fe8ff5bf /c/tree/main.c | |
parent | 9b586cd78e2e87634582bf4d58c6897703c98af9 (diff) |
rewrite program
Diffstat (limited to 'c/tree/main.c')
-rw-r--r-- | c/tree/main.c | 44 |
1 files changed, 6 insertions, 38 deletions
diff --git a/c/tree/main.c b/c/tree/main.c index 75a1939..86d2c30 100644 --- a/c/tree/main.c +++ b/c/tree/main.c @@ -4,26 +4,7 @@ * @created : Friday Nov 25, 2022 20:22:14 CST */ -#include <stdio.h> -#include <unistd.h> -#include <dirent.h> -#include <stdlib.h> -#include <string.h> -#include <stdbool.h> -#include <sys/stat.h> - -typedef struct regularFile { - char * text; - int level; -} regf; - -regf rf = {NULL,0}; - -void error(const char * str) -{ - perror(str); - exit(EXIT_FAILURE); -} +#include "tree.h" bool checkdir(const char * dir) { @@ -33,21 +14,6 @@ bool checkdir(const char * dir) return S_ISDIR(st.st_mode); } -void append(const char * dir) - -void getFiles(const char * cur) -{ - DIR * d = opendir(cur); - struct dirent * dir; - - if (!d) - error("Failed to open directory"); - - while ((dir = readdir(d))) { - if (dir && (dir[0] == '.' && dir[1] == '\0' || dir[1] == '0')) - continue; - append(dir->d_name, level); - void printChild(const char * cur) { DIR * d = opendir(cur); @@ -71,9 +37,11 @@ void printChild(const char * cur) int main() { - char * cur = "."; - - printChild(cur); + regfile head; + getfile(&head,"."); + + empty(&head); + return 0; } |