tronkko/dirent
FreeC/C++ library for retrieving information on files and directories
FreeFree tier
About tronkko/dirent
Dirent is a C/C++ library that provides a compatible programming interface for retrieving information about files and directories on Microsoft Windows and Linux/UNIX. Originally based on the POSIX standard, it allows developers to scan directories and access file entries using the familiar dirent.h API. The library supports multiple installation methods, including manual header inclusion, CMake subdirectory, FetchContent from GitHub, and system-wide CMake install. It requires Microsoft Visual Studio 2017 or later and CMake 3.13 or later for building unit tests and examples. Dirent is open source and available under a permissive license.
Key Features
POSIX-compatible dirent.h API for Microsoft Windows
Cross-platform directory scanning (Windows and Linux/UNIX)
Multiple installation methods: manual header copy, CMake subdirectory, FetchContent, system install
Open source and free to use
Supports Microsoft Visual Studio 2017+ and CMake 3.13+
Includes unit tests and example programs
Pros & Cons
Pros
- Provides a consistent API across Windows and POSIX systems
- Easy integration with CMake-based projects
- Open source with permissive license
- Lightweight: just a single header file for basic use
- Actively maintained with regular releases
Cons
- Limited to directory iteration; does not handle file I/O or other file system operations
- Manual installation on Windows may require extra steps for non-CMake projects
- Only supports C/C++ (not other languages)
Best For
Cross-platform file and directory enumeration in C/C++ applicationsPorting Linux/UNIX file system code to WindowsBuilding tools that need to list directory contents on Windows without platform-specific APIs