summaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c33
1 files changed, 32 insertions, 1 deletions
diff --git a/src/main.c b/src/main.c
index fc1044a..cacbc4f 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1,3 +1,5 @@
1#define _GNU_SOURCE
2
1#include "shared.h" 3#include "shared.h"
2#include "arena.h" 4#include "arena.h"
3#include "encryption.h" 5#include "encryption.h"
@@ -9,8 +11,37 @@
9 11
10#include <string.h> 12#include <string.h>
11#include <stdlib.h> 13#include <stdlib.h>
14
15
16#include <dirent.h>
17int selector(const struct dirent *ent) {
18 // non-zero value includes a file, zero value excludes it
19 if(strcmp(ent->d_name, ".") == 0 || strcmp(ent->d_name, "..") == 0)
20 return 0;
21
22 return 1;
23}
24
12int main() { 25int main() {
13 error(1, ENOTSUP, "No main file lol"); 26 // error(1, ENOTSUP, "No main file lol");
27
28 // Sample code on scanning the file system
29
30 struct dirent **namelist = NULL;
31 int numentries = scandir(".", &namelist, selector, alphasort);
32 if(numentries < 0)
33 error(1, errno, "Ran into error scanning dir");
34
35 dlinkedlist *ll = dlinkedlist_init();
36 for(int i = 0; i < numentries; i++) {
37 if(dlinkedlist_append(ll, (void *)namelist[i], free) != 0)
38 error(1, errno, "Could not add file entry to linked list");
39
40 free(namelist[i]);
41 }
42 free(namelist);
43
44 dlinkedlist_free(&ll);
14 45
15 return 0; 46 return 0;
16} \ No newline at end of file 47} \ No newline at end of file