Use path_is_directory from retro_dirent.c

This commit is contained in:
twinaphex 2015-09-21 23:20:33 +02:00
parent 4d8b3c4c48
commit f581dce1f7

View File

@ -35,6 +35,7 @@
#endif #endif
#include <boolean.h> #include <boolean.h>
#include <file/file_path.h>
struct RDIR struct RDIR
{ {
@ -148,22 +149,13 @@ bool retro_dirent_is_dir(struct RDIR *rdir, const char *path)
const struct dirent *entry = (const struct dirent*)rdir->entry; const struct dirent *entry = (const struct dirent*)rdir->entry;
if (entry->d_type == DT_DIR) if (entry->d_type == DT_DIR)
return true; return true;
else if (entry->d_type == DT_UNKNOWN /* This can happen on certain file systems. */ /* This can happen on certain file systems. */
|| entry->d_type == DT_LNK) if (entry->d_type == DT_UNKNOWN || 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; return false;
#else /* dirent struct doesn't have d_type, do it the slow way ... */ #else
struct stat buf; /* dirent struct doesn't have d_type, do it the slow way ... */
if (stat(path, &buf) < 0) return path_is_directory(path);
return false;
return S_ISDIR(buf.st_mode);
#endif #endif
} }