aboutsummaryrefslogtreecommitdiffstats
path: root/com32/modules/dir.c
blob: badc37de27e19dfee13497901efc19e78030d194 (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
29
30
31
32
33
34
35
36
/*
 * A dir test module
 */
#include <stdio.h>
#include <console.h>
#include <string.h>
#include <com32.h>
#include <dirent.h>

int main(int argc, char *argv[])
{
	DIR *dir;
	struct dirent *de;
	
	openconsole(&dev_null_r, &dev_stdcon_w);

	if (argc != 2) {
		printf("Usage: dir direcotry\n");
		return 0;
	}
	
	dir = opendir(argv[1]);
	printf("back from in main ...? \n");
	if (dir == NULL) {
		printf("Unable to read dir: %s\n", argv[1]);
		return 0;
	}
		
	while ((de = readdir(dir)) != NULL)
		printf("%s\n", de->d_name);
	
	closedir(dir);
	
	return 0;
}