mirror of
https://github.com/libretro/RetroArch
synced 2025-02-25 21:41:03 +00:00
Further cleanups to dir_list_new
This commit is contained in:
parent
88c8c3b81e
commit
e0a364786c
@ -89,6 +89,7 @@ void dir_list_free(struct string_list *list)
|
|||||||
string_list_free(list);
|
string_list_free(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
static bool dirent_is_directory(const char *path,
|
static bool dirent_is_directory(const char *path,
|
||||||
const struct dirent *entry)
|
const struct dirent *entry)
|
||||||
{
|
{
|
||||||
@ -105,6 +106,7 @@ static bool dirent_is_directory(const char *path,
|
|||||||
return path_is_directory(path);
|
return path_is_directory(path);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Return values:
|
/* Return values:
|
||||||
* -1 - error
|
* -1 - error
|
||||||
@ -163,21 +165,28 @@ static int parse_dir_entry(const char *name, char *file_path,
|
|||||||
struct string_list *dir_list_new(const char *dir,
|
struct string_list *dir_list_new(const char *dir,
|
||||||
const char *ext, bool include_dirs)
|
const char *ext, bool include_dirs)
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
|
||||||
char path_buf[PATH_MAX];
|
char path_buf[PATH_MAX];
|
||||||
|
struct string_list *ext_list, *list;
|
||||||
|
#ifdef _WIN32
|
||||||
WIN32_FIND_DATA ffd;
|
WIN32_FIND_DATA ffd;
|
||||||
struct string_list *ext_list = NULL;
|
|
||||||
HANDLE hFind = INVALID_HANDLE_VALUE;
|
HANDLE hFind = INVALID_HANDLE_VALUE;
|
||||||
struct string_list *list = string_list_new();
|
#else
|
||||||
|
DIR *directory = NULL;
|
||||||
|
const struct dirent *entry = NULL;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!list)
|
ext_list = NULL;
|
||||||
|
(void)path_buf;
|
||||||
|
|
||||||
|
if (!(list = string_list_new()))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
snprintf(path_buf, sizeof(path_buf), "%s\\*", dir);
|
|
||||||
|
|
||||||
if (ext)
|
if (ext)
|
||||||
ext_list = string_split(ext, "|");
|
ext_list = string_split(ext, "|");
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
snprintf(path_buf, sizeof(path_buf), "%s\\*", dir);
|
||||||
|
|
||||||
hFind = FindFirstFile(path_buf, &ffd);
|
hFind = FindFirstFile(path_buf, &ffd);
|
||||||
if (hFind == INVALID_HANDLE_VALUE)
|
if (hFind == INVALID_HANDLE_VALUE)
|
||||||
goto error;
|
goto error;
|
||||||
@ -210,17 +219,6 @@ error:
|
|||||||
if (hFind != INVALID_HANDLE_VALUE)
|
if (hFind != INVALID_HANDLE_VALUE)
|
||||||
FindClose(hFind);
|
FindClose(hFind);
|
||||||
#else
|
#else
|
||||||
DIR *directory = NULL;
|
|
||||||
const struct dirent *entry = NULL;
|
|
||||||
struct string_list *ext_list = NULL;
|
|
||||||
struct string_list *list = string_list_new();
|
|
||||||
|
|
||||||
if (!list)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
if (ext)
|
|
||||||
ext_list = string_split(ext, "|");
|
|
||||||
|
|
||||||
directory = opendir(dir);
|
directory = opendir(dir);
|
||||||
if (!directory)
|
if (!directory)
|
||||||
goto error;
|
goto error;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user