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