Welcome to mirror list, hosted at ThFree Co, Russian Federation.

random_access_sample.c « samples - github.com/cxong/tinydir.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: ea0e7e9eb13b23107d58c73dd8976cce812dfc78 (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
#include <stdio.h>
#include <tinydir.h>

int main(int argc, char *argv[])
{
	tinydir_dir dir;
	size_t i;
	if (tinydir_open_sorted(&dir, argc >= 2 ? argv[1] : ".") == -1)
	{
		perror("Error opening file");
		goto bail;
	}

	for (i = 0; i < dir.n_files; i++)
	{
		tinydir_file file;
		if (tinydir_readfile_n(&dir, &file, i) == -1)
		{
			perror("Error getting file");
			goto bail;
		}

		printf("%s", file.name);
		if (file.is_dir)
		{
			printf("/");
		}
		printf("\n");
	}

bail:
	tinydir_close(&dir);
	return 0;
}