1
2 #include <stdio.h>
3 #include <stdlib.h>
4 #include <string.h>
5 #include <time.h>
6
7 // Castor Only
8 #include <syscall.h>
9 #include <sys/syscall.h>
10 #include <sys/dirent.h>
11
12 int
main(int argc,const char * argv[])13 main(int argc, const char *argv[])
14 {
15 int fd;
16 int status;
17 uintptr_t offset = 0;
18
19 if (argc != 2) {
20 fputs("Requires an argument\n", stdout);
21 return 1;
22 }
23
24 fd = OSOpen(argv[1], 0);
25 if (fd < 0) {
26 fputs("Cannot open directory\n", stdout);
27 return 1;
28 }
29
30 while (1) {
31 struct dirent de;
32
33 status = OSReadDir(fd, (char *)&de, sizeof(de), &offset);
34 if (status == 0) {
35 break;
36 }
37 if (status < 0) {
38 printf("OSReadDir Error: %x\n", -status);
39 return 1;
40 }
41
42 printf("%s\n", de.d_name);
43 }
44
45 return 0;
46 }
47
48