Dirent is an application programming interface (API) for scanning files and directories.
Dirent is commonly used in UNIX systems but only a few compilers in Windows provide an equivalent programming interface. In particular, Microsoft Visual C++ provides two distinct programming interfaces for the job but neither of these interfaces is compatible with Dirent. Hence, if you are porting UNIX software to Windows, you may find yourself rewriting your programs for Microsoft specific APIs.
In order to ease porting of UNIX software to Windows, I have create a clone of the Dirent API for Microsoft Visual C++. The clone attempts to mimic the genuine UNIX API so that you may use the familiar UNIX data structures and function calls in both Windows and UNIX without modifying your source code for one platform or the other.
At first, download the Dirent installation package from softagalleria.net. The latest version is 1.9.
To install Dirent, unpack the zip file and copy the
dirent.h file to the system include directory. The 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 8\VC\include.
The Dirent API is implemented completely in the
dirent.h file and you can use
Dirent just like in UNIX once you copy the file.
The zip package also contains an example program with Visual Studio 2005 project file. More information about Dirent API can be found at opengroup.com.
I created the Dirent API 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 even provide a full Dirent API for Windows as well as many other UNIX APIs. MingW can even be used for commercial applications.