diff --git a/menu/menu_shader.c b/menu/menu_shader.c index da82c043ea..30abb050ff 100644 --- a/menu/menu_shader.c +++ b/menu/menu_shader.c @@ -20,6 +20,7 @@ #include #include #include +#include #ifdef HAVE_CONFIG_H #include "../config.h" @@ -101,20 +102,48 @@ bool menu_shader_manager_init(void) fill_pathname_join(preset_path, shader_dir, "menu.glslp", sizeof(preset_path)); - conf = config_file_new(preset_path); + + { + int64_t length = 0; + uint8_t *ret_buf = NULL; + if (filestream_read_file(preset_path, (void**)&ret_buf, &length)) + { + if (length >= 0) + conf = config_file_new_from_string((const char*)ret_buf); + free((void*)ret_buf); + } + } if (!conf) { fill_pathname_join(preset_path, shader_dir, "menu.cgp", sizeof(preset_path)); - conf = config_file_new(preset_path); + { + int64_t length = 0; + uint8_t *ret_buf = NULL; + if (filestream_read_file(preset_path, (void**)&ret_buf, &length)) + { + if (length >= 0) + conf = config_file_new_from_string((const char*)ret_buf); + free((void*)ret_buf); + } + } } if (!conf) { fill_pathname_join(preset_path, shader_dir, "menu.slangp", sizeof(preset_path)); - conf = config_file_new(preset_path); + { + int64_t length = 0; + uint8_t *ret_buf = NULL; + if (filestream_read_file(preset_path, (void**)&ret_buf, &length)) + { + if (length >= 0) + conf = config_file_new_from_string((const char*)ret_buf); + free((void*)ret_buf); + } + } } new_path = strdup(preset_path); @@ -149,6 +178,8 @@ bool menu_shader_manager_init(void) bool menu_shader_manager_set_preset(void *data, enum rarch_shader_type type, const char *preset_path) { + int64_t length = 0; + uint8_t *ret_buf = NULL; struct video_shader *shader = (struct video_shader*)data; config_file_t *conf = NULL; bool refresh = false; @@ -174,11 +205,17 @@ 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); + if (filestream_read_file(preset_path, (void**)&ret_buf, &length)) + { + if (length >= 0) + conf = config_file_new_from_string((const char*)ret_buf); + free((void*)ret_buf); + } if (!conf) return false; + conf->path = strdup(preset_path); RARCH_LOG("Setting Menu shader: %s.\n", preset_path); if (video_shader_read_conf_preset(conf, shader))