mirror of
https://github.com/libretro/RetroArch
synced 2024-12-28 09:29:16 +00:00
Set up dir_list_new so that we can use it for the 360/PS3 filebrowser
This commit is contained in:
parent
3a01bad0ec
commit
df6a9a0f85
@ -87,7 +87,7 @@ const char *rarch_manage_libretro_set_first_file(const char *libretro_path, cons
|
||||
//We need to set libretro to the first entry in the cores
|
||||
//directory so that it will be saved to the config file
|
||||
|
||||
char ** dir_list = dir_list_new(libretro_path, exe_ext);
|
||||
char ** dir_list = dir_list_new(libretro_path, exe_ext, false);
|
||||
|
||||
const char * retstr = NULL;
|
||||
const char * first_exe;
|
||||
|
@ -87,9 +87,9 @@ static void find_and_set_first_file(void)
|
||||
// we can find in the RetroArch cores directory
|
||||
|
||||
#if defined(_XBOX)
|
||||
char ** dir_list = dir_list_new("game:\\", ".xex");
|
||||
char ** dir_list = dir_list_new("game:\\", ".xex", false);
|
||||
#elif defined(__CELLOS_LV2__)
|
||||
char ** dir_list = dir_list_new(LIBRETRO_DIR_PATH, ".SELF");
|
||||
char ** dir_list = dir_list_new(LIBRETRO_DIR_PATH, ".SELF", false);
|
||||
#endif
|
||||
|
||||
if (!dir_list)
|
||||
|
2
driver.c
2
driver.c
@ -471,7 +471,7 @@ static void init_shader_dir(void)
|
||||
if (!*g_settings.video.shader_dir)
|
||||
return;
|
||||
|
||||
g_extern.shader_dir.elems = dir_list_new(g_settings.video.shader_dir, ".shader");
|
||||
g_extern.shader_dir.elems = dir_list_new(g_settings.video.shader_dir, ".shader", false);
|
||||
g_extern.shader_dir.size = 0;
|
||||
g_extern.shader_dir.ptr = 0;
|
||||
if (g_extern.shader_dir.elems)
|
||||
|
2
file.h
2
file.h
@ -43,7 +43,7 @@ bool init_rom_file(enum rarch_game_type type);
|
||||
// Returns a NULL-terminated list of files in a directory with full paths.
|
||||
// If ext is NULL, any file will be picked.
|
||||
// If non-NULL, only files with extension ext are added.
|
||||
char **dir_list_new(const char *dir, const char *ext);
|
||||
char **dir_list_new(const char *dir, const char *ext, bool include_dirs);
|
||||
void dir_list_free(char **dir_list);
|
||||
|
||||
bool path_is_directory(const char *path);
|
||||
|
34
file_path.c
34
file_path.c
@ -43,7 +43,7 @@
|
||||
#endif
|
||||
|
||||
// Yep, this is C alright ;)
|
||||
char **dir_list_new(const char *dir, const char *ext)
|
||||
char **dir_list_new(const char *dir, const char *ext, bool include_dirs)
|
||||
{
|
||||
size_t cur_ptr = 0;
|
||||
size_t cur_size = 32;
|
||||
@ -94,13 +94,29 @@ char **dir_list_new(const char *dir, const char *ext)
|
||||
{
|
||||
// Not a perfect search of course, but hopefully good enough in practice.
|
||||
#ifdef _WIN32
|
||||
if (ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
||||
continue;
|
||||
if (ext && !strstr(ffd.cFileName, ext))
|
||||
continue;
|
||||
if (include_dirs)
|
||||
{
|
||||
if (ext && !strstr(ffd.cFileName, ext) && !path_is_directory(ffd.cFileName))
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
||||
continue;
|
||||
if (ext && !strstr(ffd.cFileName, ext))
|
||||
continue;
|
||||
}
|
||||
#else
|
||||
if (ext && !strstr(entry->d_name, ext))
|
||||
continue;
|
||||
if (include_dirs)
|
||||
{
|
||||
if (ext && !strstr(entry->d_name, ext) && !path_is_directory(entry->d_name))
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ext && !strstr(entry->d_name, ext))
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
|
||||
dir_list[cur_ptr] = (char*)malloc(PATH_MAX);
|
||||
@ -175,10 +191,6 @@ bool path_is_directory(const char *path)
|
||||
return false;
|
||||
|
||||
return buf.st_mode & CELL_FS_S_IFDIR;
|
||||
#elif defined(XENON)
|
||||
// Dummy
|
||||
(void)path;
|
||||
return false;
|
||||
#else
|
||||
struct stat buf;
|
||||
if (stat(path, &buf) < 0)
|
||||
|
@ -1535,7 +1535,7 @@ static void set_savestate_auto_index(void)
|
||||
|
||||
unsigned max_index = 0;
|
||||
|
||||
char **dir_list = dir_list_new(dir, NULL);
|
||||
char **dir_list = dir_list_new(dir, NULL, false);
|
||||
if (!dir_list)
|
||||
return;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user