diff --git a/command.c b/command.c index f81d099bb9..4318179ead 100644 --- a/command.c +++ b/command.c @@ -953,7 +953,6 @@ static bool command_event_disk_control_append_image(const char *path) unsigned new_idx; char msg[128] = {0}; struct retro_game_info info = {0}; - global_t *global = global_get_ptr(); const struct retro_disk_control_callback *control = NULL; rarch_system_info_t *sysinfo = NULL; @@ -985,7 +984,7 @@ static bool command_event_disk_control_append_image(const char *path) command_event(CMD_EVENT_AUTOSAVE_DEINIT, NULL); /* TODO: Need to figure out what to do with subsystems case. */ - if (string_is_empty(global->subsystem)) + if (path_is_subsystem_empty()) { /* Update paths for our new image. * If we actually use append_image, we assume that we @@ -2453,17 +2452,6 @@ bool command_event(enum event_command cmd, void *data) case CMD_EVENT_TEMPORARY_CONTENT_DEINIT: content_deinit(); break; - case CMD_EVENT_SUBSYSTEM_FULLPATHS_DEINIT: - { - global_t *global = global_get_ptr(); - if (!global) - break; - - if (global->subsystem_fullpaths) - string_list_free(global->subsystem_fullpaths); - global->subsystem_fullpaths = NULL; - } - break; case CMD_EVENT_LOG_FILE_DEINIT: retro_main_log_file_deinit(); break; diff --git a/command.h b/command.h index f07078c671..82a69977e4 100644 --- a/command.h +++ b/command.h @@ -191,7 +191,6 @@ enum event_command CMD_EVENT_RESIZE_WINDOWED_SCALE, /* Deinitializes temporary content. */ CMD_EVENT_TEMPORARY_CONTENT_DEINIT, - CMD_EVENT_SUBSYSTEM_FULLPATHS_DEINIT, CMD_EVENT_LOG_FILE_DEINIT, /* Toggles disk eject. */ CMD_EVENT_DISK_EJECT_TOGGLE, diff --git a/paths.c b/paths.c index e929d53b6d..823fa916b2 100644 --- a/paths.c +++ b/paths.c @@ -48,8 +48,13 @@ #define MENU_VALUE_NO_CORE 0x7d5472cbU +/* For --subsystem content. */ +static struct string_list *subsystem_fullpaths = NULL; + +char subsystem_path[PATH_MAX_LENGTH] = {0}; + static char path_default_shader_preset[PATH_MAX_LENGTH] = {0}; -static char path_main_basename[PATH_MAX_LENGTH] = {0} +static char path_main_basename[PATH_MAX_LENGTH] = {0} ; static char path_content[PATH_MAX_LENGTH] = {0}; static char current_savefile_dir[PATH_MAX_LENGTH] = {0}; @@ -242,6 +247,11 @@ void path_set_basename(const char *path) *dst = '\0'; } +struct string_list *path_get_subsystem_list(void) +{ + return subsystem_fullpaths; +} + const char *path_get_current_savefile_dir(void) { char *ret = current_savefile_dir; @@ -263,13 +273,13 @@ void path_set_special(char **argv, unsigned num_content) /* First content file is the significant one. */ path_set_basename(argv[0]); - global->subsystem_fullpaths = string_list_new(); - retro_assert(global->subsystem_fullpaths); + subsystem_fullpaths = string_list_new(); + retro_assert(subsystem_fullpaths); attr.i = 0; for (i = 0; i < num_content; i++) - string_list_append(global->subsystem_fullpaths, argv[i], attr); + string_list_append(subsystem_fullpaths, argv[i], attr); /* We defer SRAM path updates until we can resolve it. * It is more complicated for special content types. */ @@ -302,7 +312,7 @@ static bool path_init_subsystem(void) if (!system) return false; - if (string_is_empty(global->subsystem)) + if (path_is_subsystem_empty()) return false; /* For subsystems, we know exactly which RAM types are supported. */ @@ -310,12 +320,12 @@ static bool path_init_subsystem(void) info = libretro_find_subsystem_info( system->subsystem.data, system->subsystem.size, - global->subsystem); + path_get_subsystem()); /* We'll handle this error gracefully later. */ num_content = MIN(info ? info->num_roms : 0, - global->subsystem_fullpaths ? - global->subsystem_fullpaths->size : 0); + path_is_subsystem_empty() ? + 0 : subsystem_fullpaths->size); for (i = 0; i < num_content; i++) @@ -337,12 +347,12 @@ static bool path_init_subsystem(void) /* Redirect content fullpath to save directory. */ strlcpy(path, dir_get_savefile(), sizeof(path)); fill_pathname_dir(path, - global->subsystem_fullpaths->elems[i].data, ext, + subsystem_fullpaths->elems[i].data, ext, sizeof(path)); } else { - fill_pathname(path, global->subsystem_fullpaths->elems[i].data, + fill_pathname(path, subsystem_fullpaths->elems[i].data, ext, sizeof(path)); } @@ -452,6 +462,11 @@ void path_fill_names(void) /* Core file path */ +const char *path_get_subsystem(void) +{ + return subsystem_path; +} + const char *path_get_basename(void) { return path_main_basename; @@ -482,6 +497,16 @@ void path_set_core(const char *path) strlcpy(path_libretro, path, sizeof(path_libretro)); } +void path_set_subsystem(const char *path) +{ + strlcpy(subsystem_path, path, sizeof(subsystem_path)); +} + +void path_clear_subsystem(void) +{ + *subsystem_path = '\0'; +} + void path_clear_core(void) { *path_libretro = '\0'; @@ -494,6 +519,14 @@ void path_clear_default_shader_preset(void) /* Config file path */ +bool path_is_subsystem_empty(void) +{ + if (string_is_empty(subsystem_path)) + return true; + + return false; +} + bool path_is_config_empty(void) { if (string_is_empty(path_config_file)) @@ -685,3 +718,10 @@ enum rarch_content_type path_is_media_type(const char *path) return RARCH_CONTENT_NONE; } + +void path_deinit_subsystem(void) +{ + if (subsystem_fullpaths) + string_list_free(subsystem_fullpaths); + subsystem_fullpaths = NULL; +} diff --git a/paths.h b/paths.h index d9216787a9..6b66490561 100644 --- a/paths.h +++ b/paths.h @@ -19,6 +19,8 @@ #include #include +#include + RETRO_BEGIN_DECLS enum rarch_content_type @@ -29,6 +31,8 @@ enum rarch_content_type RARCH_CONTENT_IMAGE }; +void path_deinit_subsystem(void); + void path_deinit_savefile(void); void path_init_savefile(void); @@ -39,6 +43,8 @@ void path_fill_names(void); /* set functions */ +void path_set_subsystem(const char *path); + void path_set_redirect(void); bool path_set_content(const char *path); @@ -67,8 +73,14 @@ size_t path_get_core_size(void); char *path_get_core_ptr(void); +/* get list functions */ + +struct string_list *path_get_subsystem_list(void); + /* get functions */ +const char *path_get_subsystem(void); + bool path_get_content(char **fullpath); const char *path_get_current_savefile_dir(void); @@ -87,6 +99,8 @@ bool path_get_default_shader_preset(char **preset); /* clear functions */ +void path_clear_subsystem(void); + void path_clear_default_shader_preset(void); void path_clear_basename(void); @@ -105,6 +119,8 @@ void path_clear_all(void); /* is functions */ +bool path_is_subsystem_empty(void); + bool path_is_core_empty(void); bool path_is_config_empty(void); diff --git a/retroarch.c b/retroarch.c index 07bfc8f803..a4aba2013c 100644 --- a/retroarch.c +++ b/retroarch.c @@ -468,7 +468,7 @@ static void retroarch_parse_input(int argc, char *argv[]) if (!current_core_explicitly_set) retroarch_set_current_core_type(CORE_TYPE_DUMMY, false); - *global->subsystem = '\0'; + path_clear_subsystem(); retroarch_override_setting_free_state(); @@ -789,7 +789,7 @@ static void retroarch_parse_input(int argc, char *argv[]) break; case RA_OPT_SUBSYSTEM: - strlcpy(global->subsystem, optarg, sizeof(global->subsystem)); + path_set_subsystem(optarg); break; case RA_OPT_FEATURES: @@ -840,13 +840,13 @@ static void retroarch_parse_input(int argc, char *argv[]) #endif } - if (string_is_empty(global->subsystem) && optind < argc) + if (path_is_subsystem_empty() && optind < argc) { /* We requested explicit ROM, so use PLAIN core type. */ retroarch_set_current_core_type(CORE_TYPE_PLAIN, false); path_set_names((const char*)argv[optind]); } - else if (!string_is_empty(global->subsystem) && optind < argc) + else if (!path_is_subsystem_empty() && optind < argc) { /* We requested explicit ROM, so use PLAIN core type. */ retroarch_set_current_core_type(CORE_TYPE_PLAIN, false); @@ -1159,8 +1159,8 @@ bool rarch_ctl(enum rarch_ctl_state state, void *data) command_event(CMD_EVENT_CORE_DEINIT, NULL); command_event(CMD_EVENT_TEMPORARY_CONTENT_DEINIT, NULL); - command_event(CMD_EVENT_SUBSYSTEM_FULLPATHS_DEINIT, NULL); + path_deinit_subsystem(); path_deinit_savefile(); rarch_ctl(RARCH_CTL_UNSET_INITED, NULL); diff --git a/runloop.c b/runloop.c index aafa0e2c74..69cbe55a1a 100644 --- a/runloop.c +++ b/runloop.c @@ -735,7 +735,8 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data) { global_t *global = NULL; command_event(CMD_EVENT_TEMPORARY_CONTENT_DEINIT, NULL); - command_event(CMD_EVENT_SUBSYSTEM_FULLPATHS_DEINIT, NULL); + + path_deinit_subsystem(); command_event(CMD_EVENT_RECORD_DEINIT, NULL); command_event(CMD_EVENT_LOG_FILE_DEINIT, NULL); diff --git a/runloop.h b/runloop.h index 1442bbdf1b..acb4b42ac5 100644 --- a/runloop.h +++ b/runloop.h @@ -154,10 +154,6 @@ typedef struct global char remapfile[PATH_MAX_LENGTH]; } name; - /* For --subsystem content. */ - char subsystem[PATH_MAX_LENGTH]; - struct string_list *subsystem_fullpaths; - struct { bool block_patch; diff --git a/tasks/task_content.c b/tasks/task_content.c index 2e0bf85d6a..45de219c1a 100644 --- a/tasks/task_content.c +++ b/tasks/task_content.c @@ -589,9 +589,9 @@ static const struct retro_subsystem_info *init_content_file_subsystem(bool *ret) { const struct retro_subsystem_info *special = NULL; rarch_system_info_t *system = NULL; - global_t *global = global_get_ptr(); + struct string_list *subsystem = path_get_subsystem_list(); - if (global && string_is_empty(global->subsystem)) + if (path_is_subsystem_empty()) { *ret = true; return NULL; @@ -602,40 +602,36 @@ static const struct retro_subsystem_info *init_content_file_subsystem(bool *ret) if (system) special = libretro_find_subsystem_info(system->subsystem.data, - system->subsystem.size, global->subsystem); + system->subsystem.size, path_get_subsystem()); if (!special) { RARCH_ERR( "Failed to find subsystem \"%s\" in libretro implementation.\n", - global->subsystem); + path_get_subsystem()); goto error; } - if (special->num_roms && !global->subsystem_fullpaths) + if (special->num_roms && !subsystem) { RARCH_ERR("%s\n", msg_hash_to_str(MSG_ERROR_LIBRETRO_CORE_REQUIRES_SPECIAL_CONTENT)); goto error; } - else if ((global - && special->num_roms) - && (special->num_roms - != global->subsystem_fullpaths->size)) + else if (special->num_roms && (special->num_roms != subsystem->size)) { RARCH_ERR("Libretro core requires %u content files for " "subsystem \"%s\", but %u content files were provided.\n", special->num_roms, special->desc, - (unsigned)global->subsystem_fullpaths->size); + (unsigned)subsystem->size); goto error; } - else if (!special->num_roms && global->subsystem_fullpaths - && global->subsystem_fullpaths->size) + else if (!special->num_roms && subsystem && subsystem->size) { RARCH_ERR("Libretro core takes no content for subsystem \"%s\", " "but %u content files were provided.\n", special->desc, - (unsigned)global->subsystem_fullpaths->size); + (unsigned)subsystem->size); goto error; } @@ -654,22 +650,21 @@ static bool init_content_file_set_attribs( const struct retro_subsystem_info *special) { union string_list_elem_attr attr; - global_t *global = global_get_ptr(); + struct string_list *subsystem = path_get_subsystem_list(); - attr.i = 0; + attr.i = 0; - if (!string_is_empty(global->subsystem) && special) + if (!path_is_subsystem_empty() && special) { unsigned i; - for (i = 0; i < global->subsystem_fullpaths->size; i++) + for (i = 0; i < subsystem->size; i++) { attr.i = special->roms[i].block_extract; attr.i |= special->roms[i].need_fullpath << 1; attr.i |= special->roms[i].required << 2; - string_list_append(content, - global->subsystem_fullpaths->elems[i].data, attr); + string_list_append(content, subsystem->elems[i].data, attr); } } else