Unix buildfix for dirent_is_directory

This commit is contained in:
krzys-h 2019-01-13 14:49:01 +01:00
parent 109de0bebb
commit 4b2278688b
4 changed files with 14 additions and 4 deletions

View File

@ -98,14 +98,14 @@ const char *retro_dirent_get_name(struct RDIR *rdir)
*
* retro_dirent_is_dir:
* @rdir : pointer to the directory entry.
* @path : path to the directory entry.
* @unused : deprecated, included for compatibility reasons, pass NULL
*
* Is the directory listing entry a directory?
*
* Returns: true if directory listing entry is
* a directory, false if not.
*/
bool retro_dirent_is_dir(struct RDIR *rdir, const char *path)
bool retro_dirent_is_dir(struct RDIR *rdir, const char *unused)
{
if (dirent_dirent_is_dir_cb != NULL)
return dirent_dirent_is_dir_cb((struct retro_vfs_dir_handle *)rdir);

View File

@ -62,13 +62,14 @@ const char *retro_dirent_get_name(struct RDIR *rdir);
*
* retro_dirent_is_dir:
* @rdir : pointer to the directory entry.
* @unused : deprecated, included for compatibility reasons, pass NULL
*
* Is the directory listing entry a directory?
*
* Returns: true if directory listing entry is
* a directory, false if not.
*/
bool retro_dirent_is_dir(struct RDIR *rdir, const char *path);
bool retro_dirent_is_dir(struct RDIR *rdir, const char *unused);
void retro_closedir(struct RDIR *rdir);

View File

@ -187,7 +187,7 @@ static int dir_list_read(const char *dir,
file_path[0] = '\0';
fill_pathname_join(file_path, dir, name, sizeof(file_path));
is_dir = retro_dirent_is_dir(entry, file_path);
is_dir = retro_dirent_is_dir(entry, NULL);
if(!is_dir)
file_ext = path_get_extension(name);

View File

@ -184,6 +184,7 @@
#include <memmap.h>
#include <encodings/utf.h>
#include <compat/fopen_utf8.h>
#include <file/file_path.h>
#define RFILE_HINT_UNBUFFERED (1 << 8)
@ -953,6 +954,7 @@ struct retro_vfs_dir_handle
struct libretro_vfs_implementation_dir
#endif
{
char* orig_path;
#if defined(_WIN32)
#if defined(LEGACY_WIN32)
WIN32_FIND_DATA entry;
@ -1013,6 +1015,8 @@ libretro_vfs_implementation_dir *retro_vfs_opendir_impl(const char *name, bool i
if (!rdir)
return NULL;
rdir->orig_path = strdup(name);
#if defined(_WIN32)
(void)path_wide;
(void)path_local;
@ -1164,6 +1168,9 @@ bool retro_vfs_dirent_is_dir_impl(libretro_vfs_implementation_dir *rdir)
return false;
#endif
/* dirent struct doesn't have d_type, do it the slow way ... */
char path[PATH_MAX_LENGTH];
path[0] = '\0';
fill_pathname_join(path, rdir->orig_path, retro_vfs_dirent_get_name_impl(rdir), sizeof(path));
if (stat(path, &buf) < 0)
return false;
return S_ISDIR(buf.st_mode);
@ -1191,6 +1198,8 @@ int retro_vfs_closedir_impl(libretro_vfs_implementation_dir *rdir)
closedir(rdir->directory);
#endif
if (rdir->orig_path)
free(rdir->orig_path);
free(rdir);
return 0;
}