Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion crnlib/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ OBJECTS = \
crn_utils.o \
crn_value.o \
crn_vector.o \
crn_zeng.o \
crn_texture_comp.o \
crn_texture_conversion.o \
crn_dds_comp.o \
Expand Down
27 changes: 25 additions & 2 deletions crnlib/crn_find_files.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,12 @@
#include "crn_winhdr.h"

#elif defined(__GNUC__)
#include <fcntl.h>
#include <fnmatch.h>
#include <dirent.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/types.h>
#endif

namespace crnlib {
Expand Down Expand Up @@ -195,6 +199,8 @@ bool find_files::find_internal(const char* pBasepath, const char* pRelpath, cons
if (!dp)
return level ? true : false;

const int dirDesc = dirfd(dp);

dynamic_string_array paths;

for (;;) {
Expand All @@ -204,8 +210,25 @@ bool find_files::find_internal(const char* pBasepath, const char* pRelpath, cons
if ((strcmp(ep->d_name, ".") == 0) || (strcmp(ep->d_name, "..") == 0))
continue;

const bool is_directory = (ep->d_type & DT_DIR) != 0;
const bool is_file = (ep->d_type & DT_REG) != 0;
bool is_directory = false, is_file = false;

if (ep->d_type != DT_UNKNOWN)
{
is_directory = (ep->d_type & DT_DIR) != 0;
is_file = (ep->d_type & DT_REG) != 0;
}
else
{
struct stat st;
if (fstatat(dirDesc, ep->d_name, &st, AT_SYMLINK_NOFOLLOW) == 0)
{
is_directory = (st.st_mode & S_IFDIR) != 0;
is_file = (st.st_mode & S_IFREG) != 0;
}
}

if (!is_directory && !is_file)
continue;

dynamic_string filename(ep->d_name);

Expand Down
2 changes: 0 additions & 2 deletions crnlib/crnlib.cbp
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,6 @@
<Unit filename="crn_vector.h" />
<Unit filename="crn_vector2d.h" />
<Unit filename="crn_winhdr.h" />
<Unit filename="crn_zeng.cpp" />
<Unit filename="crn_zeng.h" />
<Unit filename="crnlib.cbp" />
<Unit filename="crnlib.cpp" />
<Unit filename="lzma_7zBuf.cpp" />
Expand Down
2 changes: 0 additions & 2 deletions crnlib/crnlib_linux.cbp
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,6 @@
<Unit filename="crn_vector.h" />
<Unit filename="crn_vector2d.h" />
<Unit filename="crn_winhdr.h" />
<Unit filename="crn_zeng.cpp" />
<Unit filename="crn_zeng.h" />
<Unit filename="crnlib.cbp" />
<Unit filename="crnlib.cpp" />
<Unit filename="lzma_7zBuf.cpp" />
Expand Down