summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/unix/system.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/src/unix/system.c b/src/unix/system.c
index 33e8243..b51be6c 100644
--- a/src/unix/system.c
+++ b/src/unix/system.c
@@ -780,11 +780,6 @@ MISC
===============================================================================
*/
-static void *copy_info(const char *name, const struct stat *st)
-{
- return FS_CopyInfo(name, st->st_size, st->st_ctime, st->st_mtime);
-}
-
/*
=================
Sys_ListFiles_r
@@ -826,7 +821,16 @@ void Sys_ListFiles_r(const char *path,
continue;
}
- if (stat(fullpath, &st) == -1) {
+ st.st_mode = 0;
+
+#ifdef _DIRENT_HAVE_D_TYPE
+ // try to avoid stat() if possible
+ if (!(flags & FS_SEARCH_EXTRAINFO)) {
+ st.st_mode = DTTOIF(ent->d_type);
+ }
+#endif
+
+ if (st.st_mode == 0 && stat(fullpath, &st) == -1) {
continue;
}
@@ -884,7 +888,10 @@ void Sys_ListFiles_r(const char *path,
// copy info off
if (flags & FS_SEARCH_EXTRAINFO) {
- info = copy_info(name, &st);
+ info = FS_CopyInfo(name,
+ st.st_size,
+ st.st_ctime,
+ st.st_mtime);
} else {
info = FS_CopyString(name);
}