Skip to content

Commit

Permalink
feat: add cross_dirent
Browse files Browse the repository at this point in the history
This adds the dirent library for windows.
https://github.com/tronkko/dirent
  • Loading branch information
aminya committed Nov 16, 2021
1 parent f3bc209 commit 5d617be
Show file tree
Hide file tree
Showing 38 changed files with 4,488 additions and 0 deletions.
24 changes: 24 additions & 0 deletions cross_dirent/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/CMakeCache.txt
/CMakeFiles
/CTestTestfile.cmake
/DartConfiguration.tcl
/Makefile
/Testing
/Win32
/cmake_install.cmake
/find
/locate
/ls
/scandir
/cat
/t-compile
/t-dirent
/t-scandir
/t-cplusplus
/t-unicode
/t-strverscmp
/t-utf8
/updatedb
/*.filters
/*.vcxproj
/*.dir
62 changes: 62 additions & 0 deletions cross_dirent/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
cmake_minimum_required (VERSION 2.8.12)
project (dirent LANGUAGES C CXX)

# User options
option(DIRENT_BUILD_TESTS "Build bundled tests" ON)
message(STATUS "Build test and example programs: ${DIRENT_BUILD_TESTS}")

# 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)
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
if(DIRENT_BUILD_TESTS)
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)
add_executable (cat examples/cat.c)
add_executable (dirls examples/dirls.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-unicode tests/t-unicode.c)
add_test_executable (t-cplusplus tests/t-cplusplus.cpp)
add_test_executable (t-strverscmp tests/t-strverscmp.c)
add_test_executable (t-utf8 tests/t-utf8.c)
endif(DIRENT_BUILD_TESTS)
41 changes: 41 additions & 0 deletions cross_dirent/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Contributing to Dirent

Dirent is an open source project and we love to receive contributions from our
community -- you! There are many ways to contribute, from writing tutorials
or blog posts, improving the documentation, submitting bug reports and
feature requests, or writing code which can be incorporated into Dirent.

For example, we are looking for contributions which

1. Improve portability of code developed for Unix/Linux to Microsoft Windows.
2. Make Dirent easier to use and/or more useful for programmers working on
Microsoft Windows platform.
3. Remove compiler warnings or fix bugs.

## How to Suggest a Feature

We use Github to host code, to track issues and to discuss about Dirent. If
you would like to suggest a feature, then open an issue at Github.

## How to Report a Bug

If you have trouble using Dirent, then try to repeat the problem with the
latest version found at Github. If the problem remains, then open an issue
at Github.

## How to Submit a Fix or an Enhancement

If you wish to contribute code, then fork the repo and test the change in your
private repo first. If the change works for you and you would like to donate
the change back to the community, then make a pull request at Github.

Before making a pull request, please consider that:

1. We can only accept contributions which are compatible with [MIT Software
License](LICENSE).
2. By making a pull request, you agree to transfer all copyrights to us.
3. Our code will be reviewed and edited by us. In particular, we may
reformat your code according to the [Linux Kernel Coding
Style](https://www.kernel.org/doc/html/v4.10/process/coding-style.html)


129 changes: 129 additions & 0 deletions cross_dirent/ChangeLog
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
2018-05-08 Toni Rönkkö

* Version 1.23.2: fixes bad scandir prototype.

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.
21 changes: 21 additions & 0 deletions cross_dirent/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 1998-2019 Toni Ronkko

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.
Loading

0 comments on commit 5d617be

Please sign in to comment.