summaryrefslogtreecommitdiff
path: root/test/misc/dirent.c
blob: 885990bf2c91db7130962fdb7ebc50fb14d091bc (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
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <dirent.h>

int main(int argc, char **argv)
{

    DIR *dirh;
    struct dirent *dirp;
    static char mydir[20] = "/tmp";

    if ((dirh = opendir(mydir)) == NULL) {
	perror("opendir");
	return 1;
    }

    for (dirp = readdir(dirh); dirp != NULL; dirp = readdir(dirh)) {
	printf("Got dir entry: %s\n",dirp->d_name);
    }

    closedir(dirh);
    return 0;
}