🛠️🐜 Antkeeper superbuild with dependencies included https://antkeeper.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

101 lines
3.3 KiB

  1. # Dirent
  2. Dirent is a C/C++ programming interface that allows programmers to retrieve
  3. information about files and directories under Linux/UNIX. This project
  4. provides Linux compatible Dirent interface for Microsoft Windows.
  5. # Installation
  6. Download the latest Dirent installation package from
  7. [GitHub](https://github.com/tronkko/dirent/releases) and
  8. unpack the installation file with 7-zip, for example. The installation
  9. package contains dirent.h file as well as a few example programs and
  10. tests.
  11. ## Install Dirent for All Programs
  12. To make dirent.h available for all C/C++ programs, simply copy the
  13. ``include/dirent.h`` file to the system include directory. System include
  14. directory contains header files such as assert.h and windows.h. In Visual
  15. Studio 2008, for example, the system include may be found at
  16. ``C:\Program Files\Microsoft Visual Studio 9.0\VC\include``.
  17. Everything you need is included in the single dirent.h file, and you can
  18. start using Dirent immediately -- there is no need to add files to your
  19. Visual Studio project.
  20. ## Embed Dirent into Your Own Project
  21. If you wish to distribute dirent.h alongside with your own source code, then
  22. copy ``include/dirent.h`` file to a new sub-directory within your project and
  23. add that directory to include path on Windows while omitting the directory
  24. under Linux/UNIX. This allows your project to be compiled against native
  25. dirent.h on Linux/UNIX while substituting the functionality on Microsoft
  26. Windows.
  27. ## Examples
  28. The installation package contains four example programs:
  29. Program | Purpose
  30. -------- | -----------------------------------------------------------------
  31. ls | List files in a directory, e.g. ls "c:\Program Files"
  32. find | Find files in subdirectories, e.g. find "c:\Program Files\CMake"
  33. updatedb | Build database of files in a drive, e.g. updatedb c:\
  34. locate | Locate a file from database, e.g. locate notepad
  35. scandir | Demonstrate scandir() function
  36. cat | Print a text file to screen
  37. To build the example programs, first install [CMake](https://cmake.org/).
  38. Then, with CMake installed, open command prompt and create a temporary
  39. directory ``c:\temp\dirent`` for the build files as
  40. ```
  41. c:\
  42. mkdir temp
  43. mkdir temp\dirent
  44. cd temp\dirent
  45. ```
  46. Generate build files as
  47. ```
  48. cmake d:\dirent
  49. ```
  50. where ``d:\dirent`` is the root directory of the Dirent package (containing
  51. this README.md and LICENSE file).
  52. Once CMake is finished, open Visual Studio, load the generated dirent.sln file
  53. from the build directory and build the solution. Once the build completes, run
  54. the example programs from the command prompt as
  55. ```
  56. cd Debug
  57. ls .
  58. find .
  59. updatedb c:\
  60. locate cmd.exe
  61. ```
  62. You can omit generation of test and example programs by appending option
  63. `-DDIRENT_BUILD_TESTS=OFF` to the CMake command line.
  64. # Copying
  65. Dirent may be freely distributed under the MIT license. See the
  66. [LICENSE](LICENSE) file for details.
  67. # Alternatives to Dirent
  68. I ported Dirent to Microsoft Windows in 1998 when only a few alternatives
  69. were available. However, the situation has changed since then and nowadays
  70. both [Cygwin](http://www.cygwin.com) and [MingW](http://www.mingw.org)
  71. allow you to compile a great number of UNIX programs in Microsoft Windows.
  72. They both provide a full dirent API as well as many other UNIX APIs. MingW
  73. can even be used for commercial applications!