mirror of
https://github.com/libretro/RetroArch.git
synced 2024-11-27 10:10:57 +00:00
Move subsystem path to paths.c
This commit is contained in:
parent
b3ec735e75
commit
a1488ae34f
14
command.c
14
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;
|
||||
|
@ -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,
|
||||
|
60
paths.c
60
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;
|
||||
}
|
||||
|
16
paths.h
16
paths.h
@ -19,6 +19,8 @@
|
||||
#include <boolean.h>
|
||||
#include <retro_common_api.h>
|
||||
|
||||
#include <lists/string_list.h>
|
||||
|
||||
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);
|
||||
|
10
retroarch.c
10
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);
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user