From 08fb644c7d101551edfe8fc2608e0ac501b3df9f Mon Sep 17 00:00:00 2001 From: "@syxhe" Date: Sun, 8 Jun 2025 17:25:13 -0500 Subject: Trim the fat --- src/scanner.c | 49 +++++++++++++++++++++++++------------------------ 1 file changed, 25 insertions(+), 24 deletions(-) (limited to 'src/scanner.c') diff --git a/src/scanner.c b/src/scanner.c index ea35e3c..2ffbea4 100644 --- a/src/scanner.c +++ b/src/scanner.c @@ -1,7 +1,6 @@ #define _GNU_SOURCE #include "shared.h" -#include "ll.h" #include "scanner.h" #include @@ -10,27 +9,29 @@ #include #include -dlinkedlist * scandirlist(const char * const dir, int (*selector)(const struct dirent *), int (*cmp)(const struct dirent **, const struct dirent **)) { - if(!dir || selector == NULL || cmp == NULL) ERRRET(EINVAL, NULL); +// dlinkedlist * scandirlist(const char * const dir, int (*selector)(const struct dirent *), int (*cmp)(const struct dirent **, const struct dirent **)) { +// if(!dir || selector == NULL || cmp == NULL) ERRRET(EINVAL, NULL); - struct dirent **namelist = NULL; - dlinkedlist *list = NULL; - int numentries = -1; - - if((numentries = scandir(dir, &namelist, selector, cmp)) < 0) - ERRRET(errno, NULL); - - list = dlinkedlist_init(); - for(int i = 0; i < numentries; i++) - if(dlinkedlist_append(list, (void *)(namelist[i]), free) < 0) { - dlinkedlist_free(list); - for(int j = i; j < numentries; j++) - free(namelist[j]); - - free(namelist); - ERRRET(errno, NULL); - } - free(namelist); - - return list; -} +// struct dirent **namelist = NULL; +// dlinkedlist *list = NULL; +// int numentries = -1; + +// if((numentries = scandir(dir, &namelist, selector, cmp)) < 0) +// ERRRET(errno, NULL); + +// list = dlinkedlist_init(); +// for(int i = 0; i < numentries; i++) +// if(dlinkedlist_append(list, (void *)(namelist[i]), free) < 0) { +// dlinkedlist_free(list); +// for(int j = i; j < numentries; j++) +// free(namelist[j]); + +// free(namelist); +// ERRRET(errno, NULL); +// } +// free(namelist); + +// return list; +// } + +// TODO: Rewrite this to use the threadpool. Each newly scanned file should be pushed onto the threadpool as an encryption task \ No newline at end of file -- cgit v1.2.3