Dirent is an application programming interface (API) that enables programmers to list files and directories. Dirent API is commonly available in UNIX systems but not all compilers in Windows provide it. In particular, Microsoft Visual Studio lacks a dirent interface.
Thus, if you are porting software to Windows, you may find yourself rewriting code for Microsoft specific APIs. In order to reduce this work, I have create a clone of the dirent interface for Microsoft Visual Studio. The interface attempts to mimic the genuine UNIX API so that you could use the familiar UNIX data structures and function calls in both Windows and UNIX without modifying source code for one platform or the other.
At first, download dirent installation package from softagalleria.net. The latest version is 1.20.1 (April 2014).
To install dirent, unpack the zip file and copy includes/dirent.h file
to system include directory. System include directory contains header
files such as assert.h and windows.h, and it is usually located at
C:\Program Files\Microsoft Visual Studio 9.0\VC\include.
Dirent API is implemented completely in the dirent.h
file and you can use dirent just as in UNIX once you haved copied the
The installation package also contains a few example programs and Visual Studio 2008 project file to get you started.
I created dirent port for Windows in 1998 when only a few alternatives were available. However, the situation has changed since then and nowadays both Cygwin and MingW compilers allow you to compile a great number of UNIX programs in Windows. Both compilers provide a full dirent API for Windows as well as many other UNIX APIs, and MingW can even be used to create commercial applications.