io: implement pre- and post-order directory traversal for windows
This commit is contained in:
32
io-test/tree.c
Normal file
32
io-test/tree.c
Normal file
@@ -0,0 +1,32 @@
|
||||
#include <blue/io/directory.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#define NRAND_NUMBERS 12
|
||||
#define NRAND_BYTES 128
|
||||
#define NRAND_DOUBLES 8
|
||||
|
||||
int main(int argc, const char **argv)
|
||||
{
|
||||
if (argc < 2) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
b_directory *dir = NULL;
|
||||
b_path *path = b_path_create_from_cstr(argv[1]);
|
||||
b_status status = b_directory_open(B_DIRECTORY_ROOT, path, &dir);
|
||||
|
||||
if (!B_OK(status)) {
|
||||
printf("cannot open %s\n", b_path_ptr(path));
|
||||
printf("%s\n", b_status_to_string(status));
|
||||
return -1;
|
||||
}
|
||||
|
||||
b_directory_iterator it = {0};
|
||||
b_directory_iterator_begin(dir, &it, B_DIRECTORY_ITERATE_PARENT_FIRST);
|
||||
while (b_directory_iterator_is_valid(&it)) {
|
||||
printf("%s\n", it.filename);
|
||||
b_directory_iterator_next(&it);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user