From 9b77a7ecae190cb0aeafc56ac481436514c0b092 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 4 Sep 2015 18:50:09 +0200 Subject: [PATCH] Don't make retro_dirent.c dependent on file/file_path.c --- libretro-common/file/retro_dirent.c | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/libretro-common/file/retro_dirent.c b/libretro-common/file/retro_dirent.c index 7310c886d1..7f96808efe 100644 --- a/libretro-common/file/retro_dirent.c +++ b/libretro-common/file/retro_dirent.c @@ -28,8 +28,6 @@ #include -#include - struct RDIR { #if defined(_WIN32) @@ -101,6 +99,14 @@ const char *retro_dirent_get_name(struct RDIR *rdir) #endif } +#if defined(__CELLOS_LV2__) + +#ifndef S_ISDIR +#define S_ISDIR(x) (x & 0040000) +#endif + +#endif + /** * * retro_dirent_is_dir: @@ -124,18 +130,28 @@ bool retro_dirent_is_dir(struct RDIR *rdir, const char *path) #elif defined(VITA) return PSP2_S_ISDIR(entry->d_stat.st_mode); #endif - +#elif defined(__CELLOS_LV2__) + return S_ISDIR(entry->d_stat.st_mode); #elif defined(DT_DIR) const struct dirent *entry = (const struct dirent*)rdir->entry; if (entry->d_type == DT_DIR) return true; else if (entry->d_type == DT_UNKNOWN /* This can happen on certain file systems. */ || entry->d_type == DT_LNK) - return path_is_directory(path); + { + struct stat buf; + if (stat(path, &buf) < 0) + return false; + + return S_ISDIR(buf.st_mode); + } return false; #else /* dirent struct doesn't have d_type, do it the slow way ... */ - const struct dirent *entry = (const struct dirent*)data; - return path_is_directory(path); + struct stat buf; + if (stat(path, &buf) < 0) + return false; + + return S_ISDIR(buf.st_mode); #endif }