in C++, what would be the best way to list all files of a directory on Windows?
On Linux or on Windows using gcc (e.g. MingW) this is easy possible with dirent.h, but what's the best way to do it on Windows when dirent.h is not available (e.g. Visual Studio)?
Should I force people do add a freely available implementation of dirent.h to their Visual Studio? Or should I write an alternative code for reading the files? If this, what would be the best code to do so?
Thanks.
dirent. h is a header file that is found only on Linux systems. It provides data structures and function calls to open and read the contents of directories. If you are trying to port Linux code that uses this header file to Windows, you will that it is not available with Visual Studio.
Description. The /usr/include/dirent. h file describes the format of a directory entry without reference to the type of underlying system. The dirent structure, defined in the dirent. h file, is used for directory access operations.
The dirent. h header file contains constants, prototypes, and typedef definitions for POSIX directory access functions.
dirent.h
is a POSIX header. On Windows you use the Find*File*()
functions in the Win32 API.
Something like Boost Filesystem would work across all of those situations.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With