summaryrefslogtreecommitdiff
path: root/c/tree/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'c/tree/main.c')
-rw-r--r--c/tree/main.c44
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;
}