From f8e94a1179633799579a09dce1841f41e3b73f05 Mon Sep 17 00:00:00 2001 From: "@syxhe" Date: Mon, 6 Jan 2025 18:34:13 -0600 Subject: Start work on encryption --- src/main.c | 55 ------------------------------------------------------- 1 file changed, 55 deletions(-) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index 4ecf545..3f6d566 100644 --- a/src/main.c +++ b/src/main.c @@ -4,64 +4,9 @@ #include #include -#include -#include -#include -#include -#include - -#include - -#include - -regex_t* initfilterregex() { - static regex_t *reg = NULL; - - if(reg != NULL) - return reg; - - reg = xcalloc(1, sizeof(*reg)); - if(regcomp(reg, "^(.{1,2})$", REG_EXTENDED | REG_ICASE | REG_NOSUB) != 0) - return NULL; - - return reg; -} - -int testfilter(const struct dirent *node) { - regex_t *reg = initfilterregex(); - - if(regexec(reg, node->d_name, 0, NULL, 0) != (REG_NOMATCH | REG_NOERROR) && S_ISDIR(DTTOIF(node->d_type))) - return 0; - - return 1; -} - int main() { - // Alright, going to start simple. First: scanning for files. I want to do this quickly and in one motion - // No reason to do things in O(n2) time if I can do it in O(n) - - int nnodes = -1; - struct dirent **nodes = NULL; - if((nnodes = scandir(".", &nodes, testfilter, alphasort)) < 0) - error(1, errno, "scandir broke"); - - for(int i = 0; i < nnodes; i++) { - printf("\"%s\"", nodes[i]->d_name); - #if defined _DIRENT_HAVE_D_TYPE - int mode = DTTOIF(nodes[i]->d_type); - printf(", Type: %s%s%s", - S_ISREG(mode) ? "Regular file" : "",\ - S_ISDIR(mode) ? "Directory" : "",\ - (!S_ISREG(mode) && !S_ISDIR(mode)) ? "Unknown" : ""); - - #endif - printf("\n"); - } - // Ok so scandir is annoying and doesn't create a linked list, but rather an array of dirent objects. This means that if I want - // to iterate over the list myself and it'll be a pain in the ass to do so. That, or I can implement a linked list, which would - // also be a pain in the ass. I'm starting to remember why I finished vxgg the way I did return 0; } \ No newline at end of file -- cgit v1.2.3