cxong/tinydir
FreeLightweight, portable and easy to integrate C directory and file reader
About cxong/tinydir
TinyDir is a lightweight, portable, and easy-to-integrate C directory and file reader implemented as a single header file (tinydir.h). It wraps the POSIX dirent API on Unix-like systems and the Windows FindFirstFile API on Windows, providing a consistent interface across platforms. Written in ANSI C (C90), it supports both POSIX and Windows, with optional Unicode support on Windows by defining UNICODE and _UNICODE. The library is open source under a Simplified BSD license, making it suitable for embedding in other projects. Known limitations include restricted path and filename sizes, a potential race condition when the directory contents change during iteration, and a 260-character maximum path length on Windows (no extended-length path support).
Key Features
Pros & Cons
- Extremely lightweight and simple to integrate (single file)
- Portable across POSIX and Windows with minimal changes
- Permissive BSD license allows use in proprietary projects
- Clear API with two usage styles (iterative and sorted) for flexibility
- Active maintenance (latest release Dec 2023, 870 stars)
- Limited to 260-character paths on Windows (no extended-length support)
- Potential race condition if directory contents change during iteration
- No support for reading file metadata beyond name and is_dir flag
- Only one header file, so no separate compilation or namespace control