#define _GNU_SOURCE #include "shared.h" #include "arena.h" #include "encryption.h" #include "ll.h" #include #include #include #include #include #include int selector(const struct dirent *ent) { // non-zero value includes a file, zero value excludes it if(strcmp(ent->d_name, ".") == 0 || strcmp(ent->d_name, "..") == 0) return 0; return 1; } int printnames(void *data) { struct dirent *node = (struct dirent *)data; printf("%s\n", (node) ? node->d_name : "null"); return 0; } int main() { // error(1, ENOTSUP, "No main file lol"); // Sample code on scanning the file system struct dirent **namelist = NULL; int numentries = scandir(".", &namelist, selector, alphasort); if(numentries < 0) error(1, errno, "Ran into error scanning dir"); dlinkedlist *list = dlinkedlist_init(); for(int i = 0; i < numentries; i++) dlinkedlist_append(list, (void *)(namelist[i]), free); free(namelist); dlinkedlist_foreach(list, printnames); dlinkedlist_free(list); return 0; }