From 5e1ed323bde55d6e72099803f5eb0f0a4ff90c01 Mon Sep 17 00:00:00 2001 From: radius Date: Sun, 4 Dec 2016 01:12:57 -0500 Subject: [PATCH 1/3] make shaders paths absolute for now --- gfx/video_shader_parse.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/gfx/video_shader_parse.c b/gfx/video_shader_parse.c index de18c48106..9af30c7141 100644 --- a/gfx/video_shader_parse.c +++ b/gfx/video_shader_parse.c @@ -149,7 +149,7 @@ static bool video_shader_parse_pass(config_file_t *conf, } strlcpy(pass->source.path, tmp_str, sizeof(pass->source.path)); - + /* Smooth */ snprintf(filter_name_buf, sizeof(filter_name_buf), "filter_linear%u", i); @@ -842,12 +842,17 @@ void video_shader_write_conf_cgp(config_file_t *conf, for (i = 0; i < shader->passes; i++) { char key[64]; + char tmp[PATH_MAX_LENGTH]; const struct video_shader_pass *pass = &shader->pass[i]; key[0] = '\0'; snprintf(key, sizeof(key), "shader%u", i); - config_set_string(conf, key, pass->source.path); + strlcpy(tmp, pass->source.path, sizeof(tmp)); + + if (!path_is_absolute(tmp)) + path_resolve_realpath(tmp, sizeof(tmp)); + config_set_string(conf, key, tmp); if (pass->filter != RARCH_FILTER_UNSPEC) { From c2acadb97968363a3d49dfe004277f2024b00fca Mon Sep 17 00:00:00 2001 From: radius Date: Sun, 4 Dec 2016 02:09:19 -0500 Subject: [PATCH 2/3] instead of writing absolute paths, try to resolve absolute paths when loading, if not fallback to relative paths --- gfx/video_shader_parse.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/gfx/video_shader_parse.c b/gfx/video_shader_parse.c index 9af30c7141..65c778b6e9 100644 --- a/gfx/video_shader_parse.c +++ b/gfx/video_shader_parse.c @@ -116,6 +116,7 @@ static bool video_shader_parse_pass(config_file_t *conf, struct video_shader_pass *pass, unsigned i) { char tmp_str[PATH_MAX_LENGTH]; + char tmp_path[PATH_MAX_LENGTH]; char shader_name[64]; char filter_name_buf[64]; char wrap_name_buf[64]; @@ -148,7 +149,16 @@ static bool video_shader_parse_pass(config_file_t *conf, return false; } - strlcpy(pass->source.path, tmp_str, sizeof(pass->source.path)); + strlcpy(tmp_path, tmp_str, sizeof(tmp_path)); + path_resolve_realpath(tmp_path, sizeof(tmp_path)); + RFILE *file = filestream_open(tmp_path, RFILE_MODE_READ_TEXT, -1); + + if (!file) + strlcpy(pass->source.path, tmp_str, sizeof(pass->source.path)); + else + strlcpy(pass->source.path, tmp_path, sizeof(pass->source.path)); + + filestream_close(file); /* Smooth */ snprintf(filter_name_buf, sizeof(filter_name_buf), "filter_linear%u", i); @@ -323,6 +333,7 @@ static bool video_shader_parse_textures(config_file_t *conf, char textures[1024]; const char *id = NULL; char *save = NULL; + char tmp_path[PATH_MAX_LENGTH]; textures[0] = '\0'; @@ -349,6 +360,16 @@ static bool video_shader_parse_textures(config_file_t *conf, return false; } + strlcpy(tmp_path, shader->lut[shader->luts].path, sizeof(tmp_path)); + path_resolve_realpath(tmp_path, sizeof(tmp_path)); + RFILE *file = filestream_open(tmp_path, RFILE_MODE_READ_TEXT, -1); + if (file) + { + strlcpy(shader->lut[shader->luts].path, + tmp_path, sizeof(shader->lut[shader->luts].path)); + } + filestream_close(file); + strlcpy(shader->lut[shader->luts].id, id, sizeof(shader->lut[shader->luts].id)); From ddf10e93f0662574e9e59893aac68f455266c467 Mon Sep 17 00:00:00 2001 From: radius Date: Sun, 4 Dec 2016 12:38:46 -0500 Subject: [PATCH 3/3] remove filestream, use path_file_exists instead --- gfx/video_shader_parse.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/gfx/video_shader_parse.c b/gfx/video_shader_parse.c index 65c778b6e9..e699776c42 100644 --- a/gfx/video_shader_parse.c +++ b/gfx/video_shader_parse.c @@ -151,15 +151,12 @@ static bool video_shader_parse_pass(config_file_t *conf, strlcpy(tmp_path, tmp_str, sizeof(tmp_path)); path_resolve_realpath(tmp_path, sizeof(tmp_path)); - RFILE *file = filestream_open(tmp_path, RFILE_MODE_READ_TEXT, -1); - if (!file) + if (!path_file_exists(tmp_path)) strlcpy(pass->source.path, tmp_str, sizeof(pass->source.path)); else strlcpy(pass->source.path, tmp_path, sizeof(pass->source.path)); - filestream_close(file); - /* Smooth */ snprintf(filter_name_buf, sizeof(filter_name_buf), "filter_linear%u", i); @@ -362,13 +359,12 @@ static bool video_shader_parse_textures(config_file_t *conf, strlcpy(tmp_path, shader->lut[shader->luts].path, sizeof(tmp_path)); path_resolve_realpath(tmp_path, sizeof(tmp_path)); - RFILE *file = filestream_open(tmp_path, RFILE_MODE_READ_TEXT, -1); - if (file) + + if (path_file_exists(tmp_path)) { strlcpy(shader->lut[shader->luts].path, tmp_path, sizeof(shader->lut[shader->luts].path)); } - filestream_close(file); strlcpy(shader->lut[shader->luts].id, id, sizeof(shader->lut[shader->luts].id));