Add conf->path for config_file_new_from_path_to_string

This commit is contained in:
twinaphex 2019-07-20 00:39:55 +02:00
parent 65a777855f
commit c2c7c106a1
3 changed files with 12 additions and 7 deletions

View File

@ -530,7 +530,8 @@ bool config_append_file(config_file_t *conf, const char *path)
return true;
}
config_file_t *config_file_new_from_string(const char *from_string)
config_file_t *config_file_new_from_string(const char *from_string,
const char *path)
{
size_t i;
struct string_list *lines = NULL;
@ -549,6 +550,9 @@ config_file_t *config_file_new_from_string(const char *from_string)
conf->include_depth = 0;
conf->guaranteed_no_duplicates = false ;
if (!string_is_empty(path))
conf->path = strdup(path);
lines = string_split(from_string, "\n");
if (!lines)
return conf;
@ -602,9 +606,9 @@ config_file_t *config_file_new_from_path_to_string(const char *path)
if (filestream_read_file(path, (void**)&ret_buf, &length))
{
if (length >= 0)
if ((conf = config_file_new_from_string((const char*)ret_buf)))
conf->path = strdup(path);
free((void*)ret_buf);
conf = config_file_new_from_string((const char*)ret_buf, path);
if ((void*)ret_buf)
free((void*)ret_buf);
}
return conf;
@ -1142,7 +1146,7 @@ static void test_config_file_parse_contains(
const char * cfgtext,
const char *key, const char *val)
{
config_file_t *cfg = config_file_new_from_string(cfgtext);
config_file_t *cfg = config_file_new_from_string(cfgtext, NULL);
char *out = NULL;
bool ok = false;

View File

@ -94,7 +94,8 @@ config_file_t *config_file_new_alloc(void);
config_file_t *config_file_new_with_callback(const char *path, config_file_cb_t *cb);
/* Load a config file from a string. */
config_file_t *config_file_new_from_string(const char *from_string);
config_file_t *config_file_new_from_string(const char *from_string,
const char *path);
config_file_t *config_file_new_from_path_to_string(const char *path);

View File

@ -407,7 +407,7 @@ static bool input_autoconfigure_joypad_from_conf_internal(
for (i = 0; input_builtin_autoconfs[i]; i++)
{
config_file_t *conf = config_file_new_from_string(
input_builtin_autoconfs[i]);
input_builtin_autoconfs[i], NULL);
if (conf && input_autoconfigure_joypad_from_conf(conf, params, task))
return true;
}