From de20d7430df08731d9108acb83e1234ba7f1fe16 Mon Sep 17 00:00:00 2001 From: Benji Dial Date: Sat, 19 Sep 2020 14:53:29 -0400 Subject: file manager --- src/kernel/main2.c | 69 ------------------------------------------------------ 1 file changed, 69 deletions(-) delete mode 100644 src/kernel/main2.c (limited to 'src/kernel/main2.c') diff --git a/src/kernel/main2.c b/src/kernel/main2.c deleted file mode 100644 index 27ef8de..0000000 --- a/src/kernel/main2.c +++ /dev/null @@ -1,69 +0,0 @@ -#include -#include "drive.h" -#include "util.h" -#include "log.h" - -static char nbuf2[11]; - -static char path_builder[200]; -static uint8_t path_builder_len; - -static char indent_builder[20]; -static uint8_t indent_builder_len; - -void reset_tree() { - path_builder[0] = '\0'; - path_builder_len = 0; - - indent_builder[0] = ' '; - indent_builder[1] = ' '; - indent_builder[2] = '\0'; - indent_builder_len = 2; -} - -void tree(struct drive *d) { - struct directory_content_info infos[100]; - uint8_t n_infos = d->enumerate_dir(d, path_builder, infos, 100); - - if (!n_infos) { - logsz(indent_builder); - logsz("(empty)\n"); - return; - } - - for (uint8_t i = 0; i < n_infos; ++i) { - logsz(indent_builder); - logsz(infos[i].name); - - if (infos[i].is_dir) { - logsz(":\n"); - - indent_builder[indent_builder_len] = ' '; - indent_builder[indent_builder_len + 1] = ' '; - indent_builder[indent_builder_len + 2] = '\0'; - indent_builder_len += 2; - - uint8_t name_length = 0; - while (infos[i].name[name_length]) - ++name_length; - - memcpy(path_builder + path_builder_len, infos[i].name, name_length + 1); - path_builder_len += name_length; - - tree(d); - - path_builder_len -= name_length; - path_builder[path_builder_len] = '\0'; - - indent_builder_len -= 2; - indent_builder[indent_builder_len] = '\0'; - } - - else { - u32_dec(infos[i].size, nbuf2); - logsz(" ("); - logsz(nbuf2); - logsz(" bytes)\n"); - } - } -} \ No newline at end of file -- cgit v1.2.3