From 4830150d228165a950caa3ac26ae4eb77537145b Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 9 Sep 2021 17:21:48 +0200 Subject: [PATCH] Move function out of retroarch.c and into menu_driver.c --- menu/menu_driver.c | 47 ++++++++++++++++++++++++++++++++++++++++++++++ menu/menu_shader.h | 6 ++++++ retroarch.c | 47 ---------------------------------------------- 3 files changed, 53 insertions(+), 47 deletions(-) diff --git a/menu/menu_driver.c b/menu/menu_driver.c index 53e0a176f8..977ab44e5b 100644 --- a/menu/menu_driver.c +++ b/menu/menu_driver.c @@ -2758,4 +2758,51 @@ bool menu_shader_manager_operate_auto_preset( return false; } + +void menu_driver_set_last_shader_path_int( + const char *shader_path, + enum rarch_shader_type *type, + char *shader_dir, size_t dir_len, + char *shader_file, size_t file_len) +{ + const char *file_name = NULL; + + if (!type || + !shader_dir || + (dir_len < 1) || + !shader_file || + (file_len < 1)) + return; + + /* Reset existing cache */ + *type = RARCH_SHADER_NONE; + shader_dir[0] = '\0'; + shader_file[0] = '\0'; + + /* If path is empty, do nothing */ + if (string_is_empty(shader_path)) + return; + + /* Get shader type */ + *type = video_shader_parse_type(shader_path); + + /* If type is invalid, do nothing */ + if (*type == RARCH_SHADER_NONE) + return; + + /* Cache parent directory */ + fill_pathname_parent_dir(shader_dir, shader_path, dir_len); + + /* If parent directory is empty, then file name + * is only valid if 'shader_path' refers to an + * existing file in the root of the file system */ + if (string_is_empty(shader_dir) && + !path_is_valid(shader_path)) + return; + + /* Cache file name */ + file_name = path_basename_nocompression(shader_path); + if (!string_is_empty(file_name)) + strlcpy(shader_file, file_name, file_len); +} #endif diff --git a/menu/menu_shader.h b/menu/menu_shader.h index 0eb83f9a55..97477883b3 100644 --- a/menu/menu_shader.h +++ b/menu/menu_shader.h @@ -176,6 +176,12 @@ bool menu_shader_manager_operate_auto_preset( const char *dir_menu_config, enum auto_shader_type type, bool apply); +void menu_driver_set_last_shader_path_int( + const char *shader_path, + enum rarch_shader_type *type, + char *shader_dir, size_t dir_len, + char *shader_file, size_t file_len); + RETRO_END_DECLS #endif diff --git a/retroarch.c b/retroarch.c index 6d63b3eeba..1c4b079f93 100644 --- a/retroarch.c +++ b/retroarch.c @@ -3297,53 +3297,6 @@ retro_time_t menu_driver_get_current_time(void) } #if defined(HAVE_CG) || defined(HAVE_GLSL) || defined(HAVE_SLANG) || defined(HAVE_HLSL) -static void menu_driver_set_last_shader_path_int( - const char *shader_path, - enum rarch_shader_type *type, - char *shader_dir, size_t dir_len, - char *shader_file, size_t file_len) -{ - const char *file_name = NULL; - - if (!type || - !shader_dir || - (dir_len < 1) || - !shader_file || - (file_len < 1)) - return; - - /* Reset existing cache */ - *type = RARCH_SHADER_NONE; - shader_dir[0] = '\0'; - shader_file[0] = '\0'; - - /* If path is empty, do nothing */ - if (string_is_empty(shader_path)) - return; - - /* Get shader type */ - *type = video_shader_parse_type(shader_path); - - /* If type is invalid, do nothing */ - if (*type == RARCH_SHADER_NONE) - return; - - /* Cache parent directory */ - fill_pathname_parent_dir(shader_dir, shader_path, dir_len); - - /* If parent directory is empty, then file name - * is only valid if 'shader_path' refers to an - * existing file in the root of the file system */ - if (string_is_empty(shader_dir) && - !path_is_valid(shader_path)) - return; - - /* Cache file name */ - file_name = path_basename_nocompression(shader_path); - if (!string_is_empty(file_name)) - strlcpy(shader_file, file_name, file_len); -} - void menu_driver_set_last_shader_preset_path(const char *path) { struct rarch_state *p_rarch = &rarch_st;