Use config_file_read where we can assume we are reading a file

This commit is contained in:
twinaphex 2019-04-22 01:56:24 +02:00
parent 16e2db25c4
commit 955a149ce9
10 changed files with 68 additions and 64 deletions

View File

@ -3816,7 +3816,7 @@ bool config_save_autoconf_profile(const char *path, unsigned user)
path_size);
}
conf = config_file_new(autoconf_file);
conf = config_file_read(autoconf_file);
if (!conf)
{

View File

@ -1,9 +1,9 @@
//
// metal_common.m
// RetroArch_Metal
//
// Created by Stuart Carnie on 5/14/18.
//
/*
* metal_common.m
* RetroArch_Metal
*
* Created by Stuart Carnie on 5/14/18.
*/
#import <Foundation/Foundation.h>
#import <Metal/Metal.h>
@ -1133,7 +1133,7 @@ typedef struct MTLALIGN(16)
[self _freeVideoShader:_shader];
_shader = nil;
config_file_t *conf = config_file_new(path.UTF8String);
config_file_t *conf = config_file_read(path.UTF8String);
struct video_shader *shader = (struct video_shader *)calloc(1, sizeof(*shader));
@try

View File

@ -773,7 +773,7 @@ static bool gl_cg_load_preset(void *data, const char *path)
return false;
RARCH_LOG("[CG]: Loading Cg meta-shader: %s\n", path);
conf = config_file_new(path);
conf = config_file_read(path);
if (!conf)
{
RARCH_ERR("Failed to load preset.\n");

View File

@ -2265,7 +2265,7 @@ gl_core_filter_chain_t *gl_core_filter_chain_create_from_preset(
if (!shader)
return nullptr;
unique_ptr<config_file_t, gl_core::ConfigDeleter> conf{ config_file_new(path) };
unique_ptr<config_file_t, gl_core::ConfigDeleter> conf{ config_file_read(path) };
if (!conf)
return nullptr;
@ -2328,11 +2328,11 @@ gl_core_filter_chain_t *gl_core_filter_chain_create_from_preset(
{
/* Allow duplicate #pragma parameter, but
* only if they are exactly the same. */
if (meta_param.desc != itr->desc ||
if (meta_param.desc != itr->desc ||
meta_param.initial != itr->initial ||
meta_param.minimum != itr->minimum ||
meta_param.maximum != itr->maximum ||
meta_param.step != itr->step)
meta_param.step != itr->step)
{
RARCH_ERR("[GLCore]: Duplicate parameters found for \"%s\", but arguments do not match.\n",
itr->id);

View File

@ -896,7 +896,7 @@ static void *gl_glsl_init(void *data, const char *path)
if (string_is_equal(path_ext, "glslp"))
{
conf = config_file_new(path);
conf = config_file_read(path);
if (conf)
{
ret = video_shader_read_conf_cgp(conf, glsl->shader);

View File

@ -2822,7 +2822,7 @@ vulkan_filter_chain_t *vulkan_filter_chain_create_from_preset(
if (!shader)
return nullptr;
unique_ptr<config_file_t, ConfigDeleter> conf{ config_file_new(path) };
unique_ptr<config_file_t, ConfigDeleter> conf{ config_file_read(path) };
if (!conf)
return nullptr;

View File

@ -207,7 +207,7 @@ static int deferred_push_cursor_manager_list_deferred(
char *rdb = NULL;
settings_t *settings = config_get_ptr();
const char *path = info->path;
config_file_t *conf = path ? config_file_new(path) : NULL;
config_file_t *conf = path ? config_file_read(path) : NULL;
if (!conf || !settings)
goto end;

View File

@ -1379,15 +1379,15 @@ static const rgui_theme_t *get_theme(rgui_t *rgui)
static void load_custom_theme(rgui_t *rgui, rgui_theme_t *theme_colors, const char *theme_path)
{
settings_t *settings = config_get_ptr();
config_file_t *conf = NULL;
char *wallpaper_key = NULL;
unsigned normal_color, hover_color, title_color,
bg_dark_color, bg_light_color,
border_dark_color, border_light_color,
shadow_color;
char wallpaper_file[PATH_MAX_LENGTH];
bool success = false;
config_file_t *conf = NULL;
char *wallpaper_key = NULL;
settings_t *settings = config_get_ptr();
bool success = false;
/* Determine which type of wallpaper to load */
switch (settings->uints.menu_rgui_aspect_ratio)
@ -1415,7 +1415,7 @@ static void load_custom_theme(rgui_t *rgui, rgui_theme_t *theme_colors, const ch
goto end;
/* Open config file */
conf = config_file_new(theme_path);
conf = config_file_read(theme_path);
if (!conf)
goto end;
@ -1447,7 +1447,8 @@ static void load_custom_theme(rgui_t *rgui, rgui_theme_t *theme_colors, const ch
if(!config_get_hex(conf, "rgui_shadow_color", &shadow_color))
shadow_color = 0xFF000000;
config_get_array(conf, wallpaper_key, wallpaper_file, sizeof(wallpaper_file));
config_get_array(conf, wallpaper_key,
wallpaper_file, sizeof(wallpaper_file));
success = true;
@ -1455,14 +1456,14 @@ end:
if (success)
{
theme_colors->normal_color = (uint32_t)normal_color;
theme_colors->hover_color = (uint32_t)hover_color;
theme_colors->title_color = (uint32_t)title_color;
theme_colors->bg_dark_color = (uint32_t)bg_dark_color;
theme_colors->bg_light_color = (uint32_t)bg_light_color;
theme_colors->border_dark_color = (uint32_t)border_dark_color;
theme_colors->normal_color = (uint32_t)normal_color;
theme_colors->hover_color = (uint32_t)hover_color;
theme_colors->title_color = (uint32_t)title_color;
theme_colors->bg_dark_color = (uint32_t)bg_dark_color;
theme_colors->bg_light_color = (uint32_t)bg_light_color;
theme_colors->border_dark_color = (uint32_t)border_dark_color;
theme_colors->border_light_color = (uint32_t)border_light_color;
theme_colors->shadow_color = (uint32_t)shadow_color;
theme_colors->shadow_color = (uint32_t)shadow_color;
/* Load wallpaper, if required */
if (!string_is_empty(wallpaper_file))
@ -1477,14 +1478,14 @@ end:
else
{
/* Use 'Classic Green' fallback */
theme_colors->normal_color = rgui_theme_classic_green.normal_color;
theme_colors->hover_color = rgui_theme_classic_green.hover_color;
theme_colors->title_color = rgui_theme_classic_green.title_color;
theme_colors->bg_dark_color = rgui_theme_classic_green.bg_dark_color;
theme_colors->bg_light_color = rgui_theme_classic_green.bg_light_color;
theme_colors->border_dark_color = rgui_theme_classic_green.border_dark_color;
theme_colors->normal_color = rgui_theme_classic_green.normal_color;
theme_colors->hover_color = rgui_theme_classic_green.hover_color;
theme_colors->title_color = rgui_theme_classic_green.title_color;
theme_colors->bg_dark_color = rgui_theme_classic_green.bg_dark_color;
theme_colors->bg_light_color = rgui_theme_classic_green.bg_light_color;
theme_colors->border_dark_color = rgui_theme_classic_green.border_dark_color;
theme_colors->border_light_color = rgui_theme_classic_green.border_light_color;
theme_colors->shadow_color = rgui_theme_classic_green.shadow_color;
theme_colors->shadow_color = rgui_theme_classic_green.shadow_color;
}
if (conf)
@ -1509,9 +1510,9 @@ static void rgui_cache_background(rgui_t *rgui)
&fb_pitch);
/* Sanity check */
if ((fb_width != rgui_background_buf.width) ||
(fb_height != rgui_background_buf.height) ||
(fb_pitch != rgui_background_buf.width << 1) ||
if ((fb_width != rgui_background_buf.width) ||
(fb_height != rgui_background_buf.height) ||
(fb_pitch != rgui_background_buf.width << 1) ||
!rgui_background_buf.data)
return;
@ -1568,26 +1569,27 @@ static void prepare_rgui_colors(rgui_t *rgui, settings_t *settings)
else
{
const rgui_theme_t *current_theme = get_theme(rgui);
theme_colors.hover_color = current_theme->hover_color;
theme_colors.normal_color = current_theme->normal_color;
theme_colors.title_color = current_theme->title_color;
theme_colors.bg_dark_color = current_theme->bg_dark_color;
theme_colors.bg_light_color = current_theme->bg_light_color;
theme_colors.border_dark_color = current_theme->border_dark_color;
theme_colors.border_light_color = current_theme->border_light_color;
theme_colors.shadow_color = current_theme->shadow_color;
}
rgui->colors.hover_color = argb32_to_pixel_platform_format(theme_colors.hover_color);
rgui->colors.normal_color = argb32_to_pixel_platform_format(theme_colors.normal_color);
rgui->colors.title_color = argb32_to_pixel_platform_format(theme_colors.title_color);
rgui->colors.bg_dark_color = argb32_to_pixel_platform_format(theme_colors.bg_dark_color);
rgui->colors.bg_light_color = argb32_to_pixel_platform_format(theme_colors.bg_light_color);
rgui->colors.border_dark_color = argb32_to_pixel_platform_format(theme_colors.border_dark_color);
rgui->colors.border_light_color = argb32_to_pixel_platform_format(theme_colors.border_light_color);
rgui->colors.shadow_color = argb32_to_pixel_platform_format(theme_colors.shadow_color);
rgui->bg_modified = true;
rgui->force_redraw = true;
theme_colors.hover_color = current_theme->hover_color;
theme_colors.normal_color = current_theme->normal_color;
theme_colors.title_color = current_theme->title_color;
theme_colors.bg_dark_color = current_theme->bg_dark_color;
theme_colors.bg_light_color = current_theme->bg_light_color;
theme_colors.border_dark_color = current_theme->border_dark_color;
theme_colors.border_light_color = current_theme->border_light_color;
theme_colors.shadow_color = current_theme->shadow_color;
}
rgui->colors.hover_color = argb32_to_pixel_platform_format(theme_colors.hover_color);
rgui->colors.normal_color = argb32_to_pixel_platform_format(theme_colors.normal_color);
rgui->colors.title_color = argb32_to_pixel_platform_format(theme_colors.title_color);
rgui->colors.bg_dark_color = argb32_to_pixel_platform_format(theme_colors.bg_dark_color);
rgui->colors.bg_light_color = argb32_to_pixel_platform_format(theme_colors.bg_light_color);
rgui->colors.border_dark_color = argb32_to_pixel_platform_format(theme_colors.border_dark_color);
rgui->colors.border_light_color = argb32_to_pixel_platform_format(theme_colors.border_light_color);
rgui->colors.shadow_color = argb32_to_pixel_platform_format(theme_colors.shadow_color);
rgui->bg_modified = true;
rgui->force_redraw = true;
}
/* ==============================
@ -1810,8 +1812,10 @@ static const uint8_t *rgui_get_symbol_data(enum rgui_symbol_type symbol)
case RGUI_SYMBOL_TEXT_CURSOR:
return rgui_symbol_data_text_cursor;
default:
return NULL;
break;
}
return NULL;
}
static void blit_symbol_regular(int x, int y,

View File

@ -77,7 +77,7 @@ bool menu_shader_manager_init(void)
if (is_preset)
{
conf = config_file_new(path_shader);
conf = config_file_read(path_shader);
new_path = strdup(path_shader);
}
else
@ -101,20 +101,20 @@ bool menu_shader_manager_init(void)
fill_pathname_join(preset_path, shader_dir,
"menu.glslp", sizeof(preset_path));
conf = config_file_new(preset_path);
conf = config_file_read(preset_path);
if (!conf)
{
fill_pathname_join(preset_path, shader_dir,
"menu.cgp", sizeof(preset_path));
conf = config_file_new(preset_path);
conf = config_file_read(preset_path);
}
if (!conf)
{
fill_pathname_join(preset_path, shader_dir,
"menu.slangp", sizeof(preset_path));
conf = config_file_new(preset_path);
conf = config_file_read(preset_path);
}
new_path = strdup(preset_path);
@ -174,7 +174,7 @@ bool menu_shader_manager_set_preset(void *data,
* Used when a preset is directly loaded.
* No point in updating when the Preset was
* created from the menu itself. */
conf = config_file_new(preset_path);
conf = config_file_read(preset_path);
if (!conf)
return false;

View File

@ -749,7 +749,7 @@ bool task_push_overlay_load_default(
if (task_queue_find(&find_data))
goto error;
conf = config_file_new(overlay_path);
conf = config_file_read(overlay_path);
if (!conf)
goto error;