• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

samples/H03-May-2022-297248

tests/H03-May-2022-2,1901,314

.travis.ymlH A D27-Oct-2017499 2519

COPYINGH A D27-Oct-20171.4 KiB2723

README.mdH A D27-Oct-20171.6 KiB8057

package.jsonH A D27-Oct-2017318 1817

tinydir.hH A D27-Oct-201717.9 KiB817670

README.md

1TinyDir
2=======
3[![Build Status](https://travis-ci.org/cxong/tinydir.svg?branch=master)](https://travis-ci.org/cxong/tinydir)
4[![Release](http://img.shields.io/github/release/cxong/tinydir.svg)](https://github.com/cxong/tinydir/releases/latest)
5
6Lightweight, portable and easy to integrate C directory and file reader. TinyDir wraps dirent for POSIX and FindFirstFile for Windows.
7
8Windows unicode is supported by defining `UNICODE` and `_UNICODE` before including `tinydir.h`.
9
10Example
11=======
12
13There are two methods. Error checking omitted:
14
15```C
16tinydir_dir dir;
17tinydir_open(&dir, "/path/to/dir");
18
19while (dir.has_next)
20{
21	tinydir_file file;
22	tinydir_readfile(&dir, &file);
23
24	printf("%s", file.name);
25	if (file.is_dir)
26	{
27		printf("/");
28	}
29	printf("\n");
30
31	tinydir_next(&dir);
32}
33
34tinydir_close(&dir);
35```
36
37```C
38tinydir_dir dir;
39int i;
40tinydir_open_sorted(&dir, "/path/to/dir");
41
42for (i = 0; i < dir.n_files; i++)
43{
44	tinydir_file file;
45	tinydir_readfile_n(&dir, &file, i);
46
47	printf("%s", file.name);
48	if (file.is_dir)
49	{
50		printf("/");
51	}
52	printf("\n");
53}
54
55tinydir_close(&dir);
56```
57
58See the `/samples` folder for more examples, including an interactive command-line directory navigator.
59
60Language
61========
62
63ANSI C, or C90.
64
65Platforms
66=========
67
68POSIX and Windows supported. Open to the possibility of supporting other platforms.
69
70License
71=======
72
73Simplified BSD; if you use tinydir you can comply by including `tinydir.h` or `COPYING` somewhere in your package.
74
75Known Limitations
76=================
77
78- Limited path and filename sizes
79- [Possible race condition bug if folder being read has changing content](https://github.com/cxong/tinydir/issues/13)
80