diff options
Diffstat (limited to 'src/main.c')
| -rw-r--r-- | src/main.c | 23 |
1 files changed, 22 insertions, 1 deletions
| @@ -1,7 +1,28 @@ | |||
| 1 | #include "shared.h" | ||
| 2 | |||
| 3 | #include <errno.h> | ||
| 4 | #include <error.h> | ||
| 1 | #include <stdio.h> | 5 | #include <stdio.h> |
| 2 | 6 | ||
| 7 | #include <fcntl.h> | ||
| 8 | #include <dirent.h> | ||
| 9 | |||
| 10 | int testfilter(const struct dirent *node) { | ||
| 11 | return 1; | ||
| 12 | } | ||
| 13 | |||
| 3 | int main() { | 14 | int main() { |
| 4 | printf("We do a little trolling it's called we do a little trolling\nGod help us all\n"); | 15 | // 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) |
| 16 | |||
| 17 | int nnodes = -1; | ||
| 18 | struct dirent **nodes = NULL; | ||
| 19 | if((nnodes = scandir(".", &nodes, testfilter, alphasort)) < 0) | ||
| 20 | error(1, errno, "scandir broke"); | ||
| 21 | |||
| 22 | for(int i = 0; i < nnodes; i++) { | ||
| 23 | printf("%s\n", nodes[i]->d_name); | ||
| 24 | |||
| 25 | } | ||
| 5 | 26 | ||
| 6 | return 0; | 27 | return 0; |
| 7 | } \ No newline at end of file | 28 | } \ No newline at end of file |
