mirror of
https://github.com/libretro/RetroArch.git
synced 2024-11-27 10:10:57 +00:00
Create dir_list_initialize/dir_list_deinitialize
This commit is contained in:
parent
cde5d37eb2
commit
8a479e6006
15
core_info.c
15
core_info.c
@ -911,26 +911,26 @@ void core_info_get_name(const char *path, char *s, size_t len,
|
|||||||
bool get_display_name)
|
bool get_display_name)
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
|
struct string_list contents;
|
||||||
const char *path_basedir = !string_is_empty(path_info) ?
|
const char *path_basedir = !string_is_empty(path_info) ?
|
||||||
path_info : dir_cores;
|
path_info : dir_cores;
|
||||||
struct string_list *contents = dir_list_new(
|
|
||||||
dir_cores, exts, false, dir_show_hidden_files, false, false);
|
|
||||||
const char *core_path_basename = path_basename(path);
|
const char *core_path_basename = path_basename(path);
|
||||||
|
|
||||||
if (!contents)
|
if (!dir_list_initialize(&contents,
|
||||||
|
dir_cores, exts, false, dir_show_hidden_files, false, false))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (i = 0; i < contents->size; i++)
|
for (i = 0; i < contents.size; i++)
|
||||||
{
|
{
|
||||||
struct config_entry_list
|
struct config_entry_list
|
||||||
*entry = NULL;
|
*entry = NULL;
|
||||||
config_file_t *conf = NULL;
|
config_file_t *conf = NULL;
|
||||||
const char *current_path = contents->elems[i].data;
|
const char *current_path = contents.elems[i].data;
|
||||||
|
|
||||||
if (!string_is_equal(path_basename(current_path), core_path_basename))
|
if (!string_is_equal(path_basename(current_path), core_path_basename))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
conf = core_info_list_iterate(contents->elems[i].data,
|
conf = core_info_list_iterate(contents.elems[i].data,
|
||||||
path_basedir);
|
path_basedir);
|
||||||
|
|
||||||
if (!conf)
|
if (!conf)
|
||||||
@ -948,8 +948,7 @@ void core_info_get_name(const char *path, char *s, size_t len,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
dir_list_free(contents);
|
dir_list_deinitialize(&contents);
|
||||||
contents = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t core_info_list_num_info_files(core_info_list_t *core_info_list)
|
size_t core_info_list_num_info_files(core_info_list_t *core_info_list)
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
#define __LIBRETRO_SDK_DIR_LIST_H
|
#define __LIBRETRO_SDK_DIR_LIST_H
|
||||||
|
|
||||||
#include <retro_common_api.h>
|
#include <retro_common_api.h>
|
||||||
|
#include <boolean.h>
|
||||||
|
|
||||||
#include <lists/string_list.h>
|
#include <lists/string_list.h>
|
||||||
|
|
||||||
@ -63,6 +64,12 @@ bool dir_list_append(struct string_list *list, const char *dir, const char *ext,
|
|||||||
struct string_list *dir_list_new(const char *dir, const char *ext,
|
struct string_list *dir_list_new(const char *dir, const char *ext,
|
||||||
bool include_dirs, bool include_hidden, bool include_compressed, bool recursive);
|
bool include_dirs, bool include_hidden, bool include_compressed, bool recursive);
|
||||||
|
|
||||||
|
bool dir_list_initialize(struct string_list *list,
|
||||||
|
const char *dir,
|
||||||
|
const char *ext, bool include_dirs,
|
||||||
|
bool include_hidden, bool include_compressed,
|
||||||
|
bool recursive);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* dir_list_sort:
|
* dir_list_sort:
|
||||||
* @list : pointer to the directory listing.
|
* @list : pointer to the directory listing.
|
||||||
@ -82,6 +89,8 @@ void dir_list_sort(struct string_list *list, bool dir_first);
|
|||||||
**/
|
**/
|
||||||
void dir_list_free(struct string_list *list);
|
void dir_list_free(struct string_list *list);
|
||||||
|
|
||||||
|
bool dir_list_deinitialize(struct string_list *list);
|
||||||
|
|
||||||
RETRO_END_DECLS
|
RETRO_END_DECLS
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -86,6 +86,13 @@ void dir_list_free(struct string_list *list)
|
|||||||
string_list_free(list);
|
string_list_free(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool dir_list_deinitialize(struct string_list *list)
|
||||||
|
{
|
||||||
|
if (!list)
|
||||||
|
return false;
|
||||||
|
return string_list_deinitialize(list);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* dir_list_read:
|
* dir_list_read:
|
||||||
* @dir : directory path.
|
* @dir : directory path.
|
||||||
@ -249,3 +256,15 @@ struct string_list *dir_list_new(const char *dir,
|
|||||||
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool dir_list_initialize(struct string_list *list,
|
||||||
|
const char *dir,
|
||||||
|
const char *ext, bool include_dirs,
|
||||||
|
bool include_hidden, bool include_compressed,
|
||||||
|
bool recursive)
|
||||||
|
{
|
||||||
|
if (!list)
|
||||||
|
return NULL;
|
||||||
|
return dir_list_append(list, dir, ext, include_dirs,
|
||||||
|
include_hidden, include_compressed, recursive);
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user