ref: 301a9f04282056141658dd122eb5a9725e0d5430
parent: 4ae3076411ebed9439a9eee3ec75d92a1b230813
parent: 62e237305076ed4f3fa70f30e4a52e074243b871
author: Simon Howard <[email protected]>
date: Mon Oct 29 14:51:37 EDT 2018
Merge branch 'master' of github.com:chocolate-doom/chocolate-doom
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -47,8 +47,10 @@
find_package(m)
include(CheckSymbolExists)
+include(CheckIncludeFile)
check_symbol_exists(strcasecmp "strings.h" HAVE_DECL_STRCASECMP)
check_symbol_exists(strncasecmp "strings.h" HAVE_DECL_STRNCASECMP)
+check_include_file("dirent.h" HAVE_DIRENT_H)
string(CONCAT WINDOWS_RC_VERSION "${PROJECT_VERSION_MAJOR}, "
"${PROJECT_VERSION_MINOR}, ${PROJECT_VERSION_PATCH}, 0")
--- a/cmake/config.h.cin
+++ b/cmake/config.h.cin
@@ -6,5 +6,6 @@
#cmakedefine HAVE_LIBSAMPLERATE
#cmakedefine HAVE_LIBPNG
+#cmakedefine HAVE_DIRENT_H
#cmakedefine01 HAVE_DECL_STRCASECMP
#cmakedefine01 HAVE_DECL_STRNCASECMP
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -46,10 +46,12 @@
gusconf.c gusconf.h
i_cdmus.c i_cdmus.h
i_endoom.c i_endoom.h
+ i_glob.c i_glob.h
i_input.c i_input.h
i_joystick.c i_joystick.h
i_swap.h
i_midipipe.c i_midipipe.h
+ i_musicpack.c
i_oplmusic.c
i_pcsound.c
i_sdlmusic.c
--- a/src/i_glob.c
+++ b/src/i_glob.c
@@ -36,6 +36,41 @@
#ifndef NO_DIRENT_IMPLEMENTATION
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+
+// Only the fields d_name and (as an XSI extension) d_ino are specified
+// in POSIX.1. Other than Linux, the d_type field is available mainly
+// only on BSD systems. The remaining fields are available on many, but
+// not all systems.
+static boolean IsDirectory(char *dir, struct dirent *de)
+{
+#if defined(_DIRENT_HAVE_D_TYPE)
+ if (de->d_type != DT_UNKNOWN && de->d_type != DT_LNK)
+ {
+ return de->d_type == DT_DIR;
+ }
+ else
+#endif
+ {
+ char *filename;
+ struct stat sb;
+ int result;
+
+ filename = M_StringJoin(dir, DIR_SEPARATOR_S, de->d_name, NULL);
+ result = stat(filename, &sb);
+ free(filename);
+
+ if (result != 0)
+ {
+ return false;
+ }
+
+ return S_ISDIR(sb.st_mode);
+ }
+}
+
struct glob_s
{
char *glob;
@@ -126,7 +161,7 @@
{
return NULL;
}
- } while (de->d_type == DT_DIR || !MatchesGlob(de->d_name, glob->glob));
+ } while (IsDirectory(glob->directory, de) || !MatchesGlob(de->d_name, glob->glob));
// Return the fully-qualified path, not just the bare filename.
free(glob->last_filename);