Skip to content

Commit

Permalink
extern: Import dirent 1.23.1 from https://github.com/tronkko/dirent
Browse files Browse the repository at this point in the history
CC-Issue #384
  • Loading branch information
drdanz committed Feb 18, 2018
1 parent 4692032 commit 3b841f2
Show file tree
Hide file tree
Showing 32 changed files with 3,344 additions and 0 deletions.
31 changes: 31 additions & 0 deletions extern/dirent/README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
Dirent

Dirent is a C/C++ programming interface that allows programmers to
retrieve information about files and directories under Linux/UNIX.
This project provides Linux compatible Dirent interface for Microsoft
Windows.

Homepage: https://github.com/tronkko/dirent

Copyright: Copyright (c) 2015 Toni Rönkkö

License: MIT
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

Version: 1.23.1
18 changes: 18 additions & 0 deletions extern/dirent/dirent/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/CMakeCache.txt
/CMakeFiles
/CTestTestfile.cmake
/DartConfiguration.tcl
/Makefile
/Testing
/Win32
/cmake_install.cmake
/find
/locate
/ls
/t-compile
/t-dirent
/updatedb
/*.filters
/*.vcxproj
/*.dir

55 changes: 55 additions & 0 deletions extern/dirent/dirent/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
cmake_minimum_required (VERSION 2.8.11)
project (dirent LANGUAGES C CXX)

# Initialize C and C++ compilers
enable_language (C CXX)

# Compile in debug mode by default
if (NOT CMAKE_BUILD_TYPE)
set (CMAKE_BUILD_TYPE Debug
CACHE STRING
"Type of build: None Debug Release RelWithDebInfo MinSizeRel."
FORCE
)
endif (NOT CMAKE_BUILD_TYPE)

# Use the include directory only on Windows
if (WIN32)
include_directories (${CMAKE_SOURCE_DIR}/include)
endif (WIN32)

# Install dirent.h
if (WIN32)
install (FILES include/dirent.h DESTINATION include)
else (WIN32)
cmake_policy(SET CMP0037 OLD) # Supress warnings about fake install
add_custom_target(install) # Fake install target
endif (WIN32)

# Add distclean target
add_custom_target (distclean
COMMAND ${CMAKE_BUILD_TOOL} clean
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_SOURCE_DIR}/distclean.cmake
)

# Build example programs
add_executable (find examples/find.c)
add_executable (ls examples/ls.c)
add_executable (locate examples/locate.c)
add_executable (updatedb examples/updatedb.c)
add_executable (scandir examples/scandir.c)

# Build test programs
include (CTest)
add_custom_target (check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C ${CMAKE_CFG_INTDIR})
function (add_test_executable TEST_NAME)
add_executable (${TEST_NAME} EXCLUDE_FROM_ALL ${ARGN})
add_test (NAME ${TEST_NAME} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} COMMAND $<TARGET_FILE:${TEST_NAME}>)
add_dependencies (check ${TEST_NAME})
endfunction (add_test_executable)

add_test_executable (t-compile tests/t-compile.c)
add_test_executable (t-dirent tests/t-dirent.c)
add_test_executable (t-scandir tests/t-scandir.c)
add_test_executable (t-cplusplus tests/t-cplusplus.cpp)

126 changes: 126 additions & 0 deletions extern/dirent/dirent/ChangeLog
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
2017-08-27 Toni Rönkkö

* Version 1.23: support readdir_r and scandir functions.

2017-07-18 Toni Rönkkö

* Created release branches v1.22 and v1.21 to Git. Published version
1.22 at softagalleria.net.

2016-09-11 Toni Rönkkö

* Version 1.22: added support for CMake. Thanks to Paul Fultz II.

2014-09-25 Toni Rönkkö

* Version 1.21: compiles correctly under Open Watcom. Thanks to
Virgil Banowetz for a patch!

2014-04-07 Toni Rönkkö

* Version 1.20.1: the zip file from the previous version did not open
correctly with Microsoft's compressed folders. Thanks to Alexandre
for info!

2014-03-17 Toni Ronkko

* Version 1.20: dirent.h compiles correctly in 64-bit architecture.
Thanks to Aaron Simmons!

2014-03-03 Toni Ronkko

* Version 1.13.2: define DT_LNK for compatibility with Unix
programs. Thanks to Joel Bruick for suggestion!

2013-01-27 Toni Ronkko

* Version 1.13.1: patch from Edward Berner fixes set_errno() on
Windows NT 4.0.

* Revised wcstombs() and mbstowcs() wrappers to make sure that they do
not write past their target string.

* PATH_MAX from windows.h includes zero terminator so there is no
need to add one extra byte to variables and structures.

2012-12-12 Toni Ronkko

* Version 1.13: use the traditional 8+3 file naming scheme if a file
name cannot be represented in the default ANSI code page. Now
compiles again with MSVC 6.0. Thanks to Konstantin Khomoutov for
testing.

2012-10-01 Toni Ronkko

* Version 1.12.1: renamed wide-character DIR structure _wDIR to
_WDIR (with capital W) in order to maintain compatibility with MingW.

2012-09-30 Toni Ronkko

* Version 1.12: define PATH_MAX and NAME_MAX. Added wide-character
variants _wDIR, _wdirent, _wopendir(), _wreaddir(), _wclosedir() and
_wrewinddir(). Thanks to Edgar Buerkle and Jan Nijtmans for ideas
and code.

* Now avoiding windows.h. This allows dirent.h to be integrated
more easily into programs using winsock. Thanks to Fernando
Azaldegui.

2011-03-15 Toni Ronkko

* Version 1.11: defined FILE_ATTRIBUTE_DEVICE for MSVC 6.0.

2010-08-11 Toni Ronkko

* Version 1.10: added d_type and d_namlen fields to dirent structure.
The former is especially useful for determining whether directory
entry represents a file or a directory. For more information, see
http://www.delorie.com/gnu/docs/glibc/libc_270.html

* Improved conformance to the standards. For example, errno is now
set properly on failure and assert() is never used. Thanks to Peter
Brockam for suggestions.

* Fixed a bug in rewinddir(): when using relative directory names,
change of working directory no longer causes rewinddir() to fail.

2009-12-15 John Cunningham

* Version 1.9: added rewinddir member function

2008-01-18 Toni Ronkko

* Version 1.8: Using FindFirstFileA and WIN32_FIND_DATAA to avoid
converting string between multi-byte and unicode representations.
This makes the code simpler and also allows the code to be compiled
under MingW. Thanks to Azriel Fasten for the suggestion.

2007-03-04 Toni Ronkko

* Bug fix: due to the strncpy_s() function this file only compiled in
Visual Studio 2005. Using the new string functions only when the
compiler version allows.

2006-11-02 Toni Ronkko

* Major update: removed support for Watcom C, MS-DOS and Turbo C to
simplify the file, updated the code to compile cleanly on Visual
Studio 2005 with both unicode and multi-byte character strings,
removed rewinddir() as it had a bug.

2006-08-20 Toni Ronkko

* Removed all remarks about MSVC 1.0, which is antiqued now.
Simplified comments by removing SGML tags.

2002-05-14 Toni Ronkko

* Embedded the function definitions directly to the header so that no
source modules need to be included in the Visual Studio project.
Removed all the dependencies to other projects so that this header
file can be used independently.

1998-05-28 Toni Ronkko

* First version.

22 changes: 22 additions & 0 deletions extern/dirent/dirent/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
The MIT License (MIT)

Copyright (c) 2015 Toni Rönkkö

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

79 changes: 79 additions & 0 deletions extern/dirent/dirent/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# Dirent
Dirent is a C/C++ programming interface that allows programmers to retrieve
information about files and directories under Linux/UNIX. This project
provides Linux compatible Dirent interface for Microsoft Windows.


# Installation

Download the latest Dirent installation package from
[GitHub](https://github.com/tronkko/dirent/releases).
Older versions can be found at
[softagalleria.net](http://softagalleria.net/download/dirent/?C=M;O=D).

Unpack the installation file with 7-zip, for example. The installation
package contains dirent.h file as well as a few example programs.


## Install Dirent for All Programs

To make dirent.h available for all C/C++ programs, simply copy the
``include/dirent.h`` file to the system include directory. System include
directory contains header files such as assert.h and windows.h. In Visual
Studio 2008, for example, the system include may be found at
``C:\Program Files\Microsoft Visual Studio 9.0\VC\include``.

Everything you need is included in the single dirent.h file, and you can
start using Dirent immediately -- there is no need to add files to your
Visual Studio project.


## Embed Dirent into Your Own Project

If you wish to distribute dirent.h alongside with your own source code, then
copy ``include/dirent.h`` file to a new sub-directory within your project and
add that directory to include path on Windows while omitting the directory
under Linux/UNIX. This allows your project to be compiled against native
dirent.h on Linux/UNIX while substituting the functionality on Microsoft
Windows.


## Building Example Programs

The installation package contains some example programs and tests under
the directories examples and tests. To run these programs, install
[CMake](https://cmake.org/).

Open command prompt, navigate to dirent directory with cd and generate
build files as

```
cmake .
```

Load the generated dirent.sln file into Visual Studio and build the
solution. Run the example programs from command prompt as

```
Debug\updatedb c:\
Debug\locate cmd.exe
Debug\ls .
Debug\find .
```


# Copying

Dirent may be freely distributed under the MIT license. See the LICENSE
file for details.


# Alternatives to Dirent

I ported Dirent to Microsoft Windows in 1998 when only a few alternatives
were available. However, the situation has changed since then and nowadays
both [Cygwin](http://www.cygwin.com) and [MingW](http://www.mingw.org)
allow you to compile a great number of UNIX programs in Microsoft Windows.
They both provide a full dirent API as well as many other UNIX APIs. MingW
can even be used for commercial applications!

Loading

0 comments on commit 3b841f2

Please sign in to comment.