mirror of
https://github.com/libretro/RetroArch
synced 2025-03-03 13:14:04 +00:00
(config_file.c) Seems unnecesary to check if a config file is a
directory first
This commit is contained in:
parent
39c3a25ad6
commit
6888a0cc71
@ -69,7 +69,7 @@ struct config_include_list
|
|||||||
};
|
};
|
||||||
|
|
||||||
static config_file_t *config_file_new_internal(
|
static config_file_t *config_file_new_internal(
|
||||||
const char *path, unsigned depth, config_file_cb_t *cb, bool no_checks);
|
const char *path, unsigned depth, config_file_cb_t *cb);
|
||||||
|
|
||||||
static int config_sort_compare_func(struct config_entry_list *a,
|
static int config_sort_compare_func(struct config_entry_list *a,
|
||||||
struct config_entry_list *b)
|
struct config_entry_list *b)
|
||||||
@ -268,8 +268,7 @@ static void add_child_list(config_file_t *parent, config_file_t *child)
|
|||||||
parent->tail = NULL;
|
parent->tail = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void add_sub_conf(config_file_t *conf, char *path, config_file_cb_t *cb,
|
static void add_sub_conf(config_file_t *conf, char *path, config_file_cb_t *cb)
|
||||||
bool no_checks)
|
|
||||||
{
|
{
|
||||||
char real_path[PATH_MAX_LENGTH];
|
char real_path[PATH_MAX_LENGTH];
|
||||||
config_file_t *sub_conf = NULL;
|
config_file_t *sub_conf = NULL;
|
||||||
@ -316,7 +315,7 @@ static void add_sub_conf(config_file_t *conf, char *path, config_file_cb_t *cb,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
sub_conf = (config_file_t*)
|
sub_conf = (config_file_t*)
|
||||||
config_file_new_internal(real_path, conf->include_depth + 1, cb, no_checks);
|
config_file_new_internal(real_path, conf->include_depth + 1, cb);
|
||||||
if (!sub_conf)
|
if (!sub_conf)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -326,8 +325,7 @@ static void add_sub_conf(config_file_t *conf, char *path, config_file_cb_t *cb,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static bool parse_line(config_file_t *conf,
|
static bool parse_line(config_file_t *conf,
|
||||||
struct config_entry_list *list, char *line, config_file_cb_t *cb,
|
struct config_entry_list *list, char *line, config_file_cb_t *cb)
|
||||||
bool no_checks)
|
|
||||||
{
|
{
|
||||||
char *key = NULL;
|
char *key = NULL;
|
||||||
char *key_tmp = NULL;
|
char *key_tmp = NULL;
|
||||||
@ -350,7 +348,7 @@ static bool parse_line(config_file_t *conf,
|
|||||||
if (conf->include_depth >= MAX_INCLUDE_DEPTH)
|
if (conf->include_depth >= MAX_INCLUDE_DEPTH)
|
||||||
fprintf(stderr, "!!! #include depth exceeded for config. Might be a cycle.\n");
|
fprintf(stderr, "!!! #include depth exceeded for config. Might be a cycle.\n");
|
||||||
else
|
else
|
||||||
add_sub_conf(conf, path, cb, no_checks);
|
add_sub_conf(conf, path, cb);
|
||||||
free(path);
|
free(path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -395,7 +393,7 @@ static bool parse_line(config_file_t *conf,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static config_file_t *config_file_new_internal(
|
static config_file_t *config_file_new_internal(
|
||||||
const char *path, unsigned depth, config_file_cb_t *cb, bool no_checks)
|
const char *path, unsigned depth, config_file_cb_t *cb)
|
||||||
{
|
{
|
||||||
RFILE *file = NULL;
|
RFILE *file = NULL;
|
||||||
struct config_file *conf = (struct config_file*)malloc(sizeof(*conf));
|
struct config_file *conf = (struct config_file*)malloc(sizeof(*conf));
|
||||||
@ -412,11 +410,6 @@ static config_file_t *config_file_new_internal(
|
|||||||
|
|
||||||
if (!path || !*path)
|
if (!path || !*path)
|
||||||
return conf;
|
return conf;
|
||||||
#if !defined(ORBIS)
|
|
||||||
if (!no_checks)
|
|
||||||
if (path_is_directory(path))
|
|
||||||
goto error;
|
|
||||||
#endif
|
|
||||||
conf->path = strdup(path);
|
conf->path = strdup(path);
|
||||||
if (!conf->path)
|
if (!conf->path)
|
||||||
goto error;
|
goto error;
|
||||||
@ -458,7 +451,7 @@ static config_file_t *config_file_new_internal(
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*line && parse_line(conf, list, line, cb, no_checks))
|
if (*line && parse_line(conf, list, line, cb))
|
||||||
{
|
{
|
||||||
if (conf->entries)
|
if (conf->entries)
|
||||||
conf->tail->next = list;
|
conf->tail->next = list;
|
||||||
@ -548,7 +541,6 @@ bool config_append_file(config_file_t *conf, const char *path)
|
|||||||
config_file_t *config_file_new_from_string(const char *from_string)
|
config_file_t *config_file_new_from_string(const char *from_string)
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
bool no_checks = false;
|
|
||||||
struct string_list *lines = NULL;
|
struct string_list *lines = NULL;
|
||||||
struct config_file *conf = (struct config_file*)malloc(sizeof(*conf));
|
struct config_file *conf = (struct config_file*)malloc(sizeof(*conf));
|
||||||
if (!conf)
|
if (!conf)
|
||||||
@ -589,7 +581,7 @@ config_file_t *config_file_new_from_string(const char *from_string)
|
|||||||
|
|
||||||
if (line && conf)
|
if (line && conf)
|
||||||
{
|
{
|
||||||
if (*line && parse_line(conf, list, line, NULL, no_checks))
|
if (*line && parse_line(conf, list, line, NULL))
|
||||||
{
|
{
|
||||||
if (conf->entries)
|
if (conf->entries)
|
||||||
conf->tail->next = list;
|
conf->tail->next = list;
|
||||||
@ -612,17 +604,17 @@ config_file_t *config_file_new_from_string(const char *from_string)
|
|||||||
config_file_t *config_file_new_with_callback(
|
config_file_t *config_file_new_with_callback(
|
||||||
const char *path, config_file_cb_t *cb)
|
const char *path, config_file_cb_t *cb)
|
||||||
{
|
{
|
||||||
return config_file_new_internal(path, 0, cb, false);
|
return config_file_new_internal(path, 0, cb);
|
||||||
}
|
}
|
||||||
|
|
||||||
config_file_t *config_file_new(const char *path)
|
config_file_t *config_file_new(const char *path)
|
||||||
{
|
{
|
||||||
return config_file_new_internal(path, 0, NULL, false);
|
return config_file_new_internal(path, 0, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
config_file_t *config_file_read(const char *path)
|
config_file_t *config_file_read(const char *path)
|
||||||
{
|
{
|
||||||
return config_file_new_internal(path, 0, NULL, true);
|
return config_file_new_internal(path, 0, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct config_entry_list *config_get_entry(
|
static struct config_entry_list *config_get_entry(
|
||||||
@ -1116,7 +1108,7 @@ bool config_get_entry_list_next(struct config_file_entry *entry)
|
|||||||
|
|
||||||
bool config_file_exists(const char *path)
|
bool config_file_exists(const char *path)
|
||||||
{
|
{
|
||||||
config_file_t *config = config_file_new(path);
|
config_file_t *config = config_file_read(path);
|
||||||
if (!config)
|
if (!config)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user