blob: bf110c25ca89538d884a03981bd90612414dbede (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
#include "shared.h"
#include <errno.h>
#include <error.h>
#include <stdio.h>
#include <fcntl.h>
#include <dirent.h>
int testfilter(const struct dirent *node) {
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\n", nodes[i]->d_name);
}
return 0;
}
|