mirror of
https://github.com/libretro/RetroArch
synced 2025-01-27 12:35:23 +00:00
(GX) use dirent.d_type for deciding filetype instead of "stat"int each file
GREATLY reduces filebrowser lag for large folders
This commit is contained in:
parent
4abe4fb6e0
commit
31272e9a9d
@ -32,7 +32,10 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <dirent.h>
|
||||||
|
#ifndef _DIRENT_HAVE_D_TYPE
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
#endif
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
|
|
||||||
@ -156,20 +159,31 @@ static bool folder_cb(const char *directory, rgui_file_enum_cb_t file_cb,
|
|||||||
{
|
{
|
||||||
char stat_path[PATH_MAX];
|
char stat_path[PATH_MAX];
|
||||||
snprintf(stat_path, sizeof(stat_path), "%s/%s", directory, entry->d_name);
|
snprintf(stat_path, sizeof(stat_path), "%s/%s", directory, entry->d_name);
|
||||||
|
|
||||||
|
#ifdef _DIRENT_HAVE_D_TYPE
|
||||||
|
if (entry->d_type != DT_REG && entry->d_type != DT_DIR)
|
||||||
|
continue;
|
||||||
|
#else
|
||||||
struct stat st;
|
struct stat st;
|
||||||
if (stat(stat_path, &st) < 0)
|
if (stat(stat_path, &st) < 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (!S_ISDIR(st.st_mode) && !S_ISREG(st.st_mode))
|
if (!S_ISDIR(st.st_mode) && !S_ISREG(st.st_mode))
|
||||||
continue;
|
continue;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (core_chooser && (strstr(entry->d_name, ".dol") != entry->d_name + strlen(entry->d_name) - 4 ||
|
if (core_chooser && (strstr(entry->d_name, default_paths.executable_extension) != entry->d_name + strlen(entry->d_name) - 4 ||
|
||||||
strcasecmp(entry->d_name, "boot.dol") == 0))
|
strcasecmp(entry->d_name, default_paths.salamander_file) == 0))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
file_cb(ctx,
|
file_cb(ctx,
|
||||||
entry->d_name, S_ISDIR(st.st_mode) ?
|
entry->d_name,
|
||||||
RGUI_FILE_DIRECTORY : RGUI_FILE_PLAIN, 0);
|
#ifdef _DIRENT_HAVE_D_TYPE
|
||||||
|
(entry->d_type == DT_DIR)
|
||||||
|
#else
|
||||||
|
S_ISDIR(st.st_mode)
|
||||||
|
#endif
|
||||||
|
? RGUI_FILE_DIRECTORY : RGUI_FILE_PLAIN, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
closedir(dir);
|
closedir(dir);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user