Start going through rarch_main_ctl for grabbing fullpath

This commit is contained in:
twinaphex 2015-11-18 11:43:25 +01:00
parent 2b727fa941
commit a4ae655ff4
15 changed files with 113 additions and 58 deletions

View File

@ -1074,15 +1074,18 @@ bool event_command(enum event_command cmd)
rarch_ctl(RARCH_ACTION_STATE_LOAD_CONTENT_IMAGEVIEWER, NULL);
break;
case EVENT_CMD_LOAD_CONTENT:
{
#ifdef HAVE_DYNAMIC
event_command(EVENT_CMD_LOAD_CONTENT_PERSIST);
#else
char *fullpath = NULL;
rarch_main_ctl(RARCH_MAIN_CTL_GET_CONTENT_PATH, &fullpath);
rarch_environment_cb(RETRO_ENVIRONMENT_SET_LIBRETRO_PATH,
(void*)settings->libretro);
rarch_environment_cb(RETRO_ENVIRONMENT_EXEC,
(void*)global->path.fullpath);
rarch_environment_cb(RETRO_ENVIRONMENT_EXEC, (void*)fullpath);
event_command(EVENT_CMD_QUIT);
#endif
}
break;
case EVENT_CMD_LOAD_CORE_DEINIT:
#ifdef HAVE_DYNAMIC
@ -1182,7 +1185,7 @@ bool event_command(enum event_command cmd)
#endif
rarch_main_data_deinit();
*global->path.fullpath = '\0';
rarch_main_ctl(RARCH_MAIN_CTL_CLEAR_CONTENT_PATH, NULL);
rarch_ctl(RARCH_ACTION_STATE_LOAD_CONTENT, NULL);
}
@ -1462,13 +1465,15 @@ bool event_command(enum event_command cmd)
rarch_ctl(RARCH_ACTION_STATE_MENU_RUNNING_FINISHED, NULL);
break;
case EVENT_CMD_RESTART_RETROARCH:
{
#if defined(GEKKO) && defined(HW_RVL)
fill_pathname_join(global->path.fullpath, g_defaults.dir.core,
SALAMANDER_FILE,
sizeof(global->path.fullpath));
char new_path[PATH_MAX_LENGTH];
fill_pathname_join(new_path, g_defaults.dir.core, SALAMANDER_FILE, sizeof(new_path));
rarch_main_ctl(RARCH_MAIN_CTL_SET_CONTENT_PATH, new_path);
#endif
if (driver->frontend_ctx && driver->frontend_ctx->set_fork)
driver->frontend_ctx->set_fork(true, false);
}
break;
case EVENT_CMD_MENU_SAVE_CURRENT_CONFIG:
event_save_current_config();

View File

@ -621,11 +621,14 @@ bool init_content_file(void)
}
else
{
char *fullpath = NULL;
rarch_main_ctl(RARCH_MAIN_CTL_GET_CONTENT_PATH, &fullpath);
attr.i = system->info.block_extract;
attr.i |= system->info.need_fullpath << 1;
attr.i |= (!system->no_content) << 2;
string_list_append(content,
(global->inited.core.no_content && settings->core.set_supports_no_game_enable) ? "" : global->path.fullpath, attr);
(global->inited.core.no_content && settings->core.set_supports_no_game_enable) ? "" : fullpath, attr);
}
#ifdef HAVE_ZLIB

View File

@ -779,8 +779,11 @@ bool rarch_environment_cb(unsigned cmd, void *data)
case RETRO_ENVIRONMENT_GET_SYSTEM_DIRECTORY:
if (settings->system_directory[0] == '\0')
{
RARCH_WARN("SYSTEM DIR is empty, assume CONTENT DIR %s\n",global->path.fullpath);
fill_pathname_basedir(global->dir.systemdir, global->path.fullpath,
char *fullpath = NULL;
rarch_main_ctl(RARCH_MAIN_CTL_GET_CONTENT_PATH, &fullpath);
RARCH_WARN("SYSTEM DIR is empty, assume CONTENT DIR %s\n", fullpath);
fill_pathname_basedir(global->dir.systemdir, fullpath,
sizeof(global->dir.systemdir));
*(const char**)data = global->dir.systemdir;
@ -1291,9 +1294,13 @@ bool rarch_environment_cb(unsigned cmd, void *data)
case RETRO_ENVIRONMENT_EXEC:
case RETRO_ENVIRONMENT_EXEC_ESCAPE:
if (global->path.fullpath != data)
{
*global->path.fullpath = '\0';
char *fullpath = NULL;
rarch_main_ctl(RARCH_MAIN_CTL_GET_CONTENT_PATH, &fullpath);
if (fullpath != data)
{
rarch_main_ctl(RARCH_MAIN_CTL_CLEAR_CONTENT_PATH, NULL);
if (data)
rarch_main_ctl(RARCH_MAIN_CTL_SET_CONTENT_PATH, data);
}
@ -1312,7 +1319,7 @@ bool rarch_environment_cb(unsigned cmd, void *data)
}
else
RARCH_LOG("Environ (Private) EXEC.\n");
}
break;
default:

View File

@ -359,6 +359,7 @@ static int frontend_ps3_exec_exitspawn(const char *path,
static void frontend_ps3_exec(const char *path, bool should_load_game)
{
#ifndef IS_SALAMANDER
char *fullpath = NULL;
global_t *global = global_get_ptr();
bool original_verbose = global->verbosity;
@ -370,10 +371,12 @@ static void frontend_ps3_exec(const char *path, bool should_load_game)
RARCH_LOG("Attempt to load executable: [%s].\n", path);
#ifndef IS_SALAMANDER
if (should_load_game && global->path.fullpath[0] != '\0')
rarch_main_ctl(RARCH_MAIN_CTL_GET_CONTENT_PATH, &fullpath);
if (should_load_game && fullpath[0] != '\0')
{
char game_path[256];
strlcpy(game_path, global->path.fullpath, sizeof(game_path));
strlcpy(game_path, fullpath, sizeof(game_path));
const char * const spawn_argv[] = {
game_path,

View File

@ -256,12 +256,13 @@ static void frontend_psp_exec(const char *path, bool should_load_game)
args = strlen(argp) + 1;
#ifndef IS_SALAMANDER
global_t *global = global_get_ptr();
char *fullpath = NULL;
rarch_main_ctl(RARCH_MAIN_CTL_GET_CONTENT_PATH, &fullpath);
if (should_load_game && global->path.fullpath[0] != '\0')
if (should_load_game && fullpath[0] != '\0')
{
argp[args] = '\0';
strlcat(argp + args, global->path.fullpath, sizeof(argp) - args);
strlcat(argp + args, fullpath, sizeof(argp) - args);
args += strlen(argp + args) + 1;
}
#endif

View File

@ -134,7 +134,9 @@ void system_exec_wii(const char *_path, bool should_load_game)
#ifdef IS_SALAMANDER
strlcpy(game_path, gx_rom_path, sizeof(game_path));
#else
strlcpy(game_path, global->path.fullpath, sizeof(game_path));
char *fullpath = NULL;
rarch_main_ctl(RARCH_MAIN_CTL_GET_CONTENT_PATH, &fullpath);
strlcpy(game_path, fullpath, sizeof(game_path));
#endif
}

View File

@ -320,21 +320,26 @@ static void frontend_xdk_exec(const char *path, bool should_load_game)
if (path[0] != '\0')
XLaunchNewImage(path, NULL);
#else
#ifdef _XBOX
char *fullpath = NULL;
menu-display_ctl(MENU_DISPLAY_CTL_GET_CONTENT_PATH, &fullpath);
#if defined(_XBOX1)
LAUNCH_DATA ptr;
memset(&ptr, 0, sizeof(ptr));
if (should_load_game && global->path.fullpath[0] != '\0')
snprintf((char*)ptr.Data, sizeof(ptr.Data), "%s", global->path.fullpath);
if (should_load_game && fullpath[0] != '\0')
snprintf((char*)ptr.Data, sizeof(ptr.Data), "%s", fullpath);
if (path[0] != '\0')
XLaunchNewImage(path, ptr.Data[0] != '\0' ? &ptr : NULL);
#elif defined(_XBOX360)
char game_path[1024] = {0};
if (should_load_game && global->path.fullpath[0] != '\0')
if (should_load_game && fullpath[0] != '\0')
{
strlcpy(game_path, global->path.fullpath, sizeof(game_path));
strlcpy(game_path, fullpath, sizeof(game_path));
XSetLaunchData(game_path, MAX_LAUNCH_DATA_SIZE);
}
@ -342,6 +347,7 @@ static void frontend_xdk_exec(const char *path, bool should_load_game)
XLaunchNewImage(path, NULL);
#endif
#endif
#endif
#ifndef IS_SALAMANDER
global->verbosity = original_verbose;
#endif

View File

@ -295,13 +295,16 @@ int rarch_main(int argc, char *argv[], void *data)
if (settings->history_list_enable)
{
char *fullpath = NULL;
global_t *global = global_get_ptr();
rarch_system_info_t *system = rarch_system_info_get_ptr();
rarch_main_ctl(RARCH_MAIN_CTL_GET_CONTENT_PATH, &fullpath);
if (global->inited.content || system->no_content)
history_playlist_push(
g_defaults.history,
global->path.fullpath,
fullpath,
settings->libretro,
system ? &system->info : NULL);
}

View File

@ -643,7 +643,7 @@ static int generic_action_ok(const char *path,
/* No content needed for this core, load core immediately. */
if (menu->load_no_content && settings->core.set_supports_no_game_enable)
{
*global->path.fullpath = '\0';
rarch_main_ctl(RARCH_MAIN_CTL_CLEAR_CONTENT_PATH, NULL);
ret = menu_common_load_content(NULL, NULL, false, CORE_TYPE_PLAIN);
if (ret == -1)
action_ok_push_quick_menu();
@ -1337,13 +1337,15 @@ static int action_ok_screenshot(const char *path,
static int action_ok_file_load_or_resume(const char *path,
const char *label, unsigned type, size_t idx, size_t entry_idx)
{
char *fullpath = NULL;
menu_handle_t *menu = menu_driver_get_ptr();
global_t *global = global_get_ptr();
if (!menu)
return -1;
if (!strcmp(menu->deferred_path, global->path.fullpath))
rarch_main_ctl(RARCH_MAIN_CTL_GET_CONTENT_PATH, &fullpath);
if (!strcmp(menu->deferred_path, fullpath))
return generic_action_ok_command(EVENT_CMD_RESUME);
rarch_main_ctl(RARCH_MAIN_CTL_SET_CONTENT_PATH, menu->deferred_path);

View File

@ -33,10 +33,13 @@ static void menu_environment_get(int *argc, char *argv[],
global_t *global = global_get_ptr();
settings_t *settings = config_get_ptr();
menu_handle_t *menu = menu_driver_get_ptr();
char *fullpath = NULL;
if (!wrap_args)
return;
rarch_main_ctl(RARCH_MAIN_CTL_GET_CONTENT_PATH, &fullpath);
wrap_args->no_content = menu->load_no_content;
if (!global->has_set.verbosity)
wrap_args->verbose = global->verbosity;
@ -44,7 +47,7 @@ static void menu_environment_get(int *argc, char *argv[],
wrap_args->config_path = *global->path.config ? global->path.config : NULL;
wrap_args->sram_path = *global->dir.savefile ? global->dir.savefile : NULL;
wrap_args->state_path = *global->dir.savestate ? global->dir.savestate : NULL;
wrap_args->content_path = *global->path.fullpath ? global->path.fullpath : NULL;
wrap_args->content_path = *fullpath ? fullpath : NULL;
if (!global->has_set.libretro)
wrap_args->libretro_path = *settings->libretro ? settings->libretro : NULL;
@ -55,22 +58,25 @@ static void menu_push_to_history_playlist(void)
{
settings_t *settings = config_get_ptr();
global_t *global = global_get_ptr();
char *fullpath = NULL;
if (!settings->history_list_enable)
return;
if (*global->path.fullpath)
rarch_main_ctl(RARCH_MAIN_CTL_GET_CONTENT_PATH, &fullpath);
if (*fullpath)
{
char tmp[PATH_MAX_LENGTH];
char str[PATH_MAX_LENGTH];
fill_pathname_base(tmp, global->path.fullpath, sizeof(tmp));
fill_pathname_base(tmp, fullpath, sizeof(tmp));
snprintf(str, sizeof(str), "INFO - Loading %s ...", tmp);
menu_display_msg_queue_push(str, 1, 1, false);
}
content_playlist_push(g_defaults.history,
global->path.fullpath,
fullpath,
NULL,
settings->libretro,
global->menu.info.library_name,
@ -91,8 +97,9 @@ bool menu_load_content(enum rarch_core_type type)
bool msg_force = true;
menu_handle_t *menu = menu_driver_get_ptr();
driver_t *driver = driver_get_ptr();
global_t *global = global_get_ptr();
char *fullpath = NULL;
rarch_main_ctl(RARCH_MAIN_CTL_GET_CONTENT_PATH, &fullpath);
/* redraw menu frame */
menu_display_ctl(MENU_DISPLAY_CTL_SET_MSG_FORCE, &msg_force);
menu_iterate_render();
@ -103,7 +110,7 @@ bool menu_load_content(enum rarch_core_type type)
char name[PATH_MAX_LENGTH] = {0};
char msg[PATH_MAX_LENGTH] = {0};
fill_pathname_base(name, global->path.fullpath, sizeof(name));
fill_pathname_base(name, fullpath, sizeof(name));
snprintf(msg, sizeof(msg), "Failed to load %s.\n", name);
menu_display_msg_queue_push(msg, 1, 90, false);
@ -114,7 +121,7 @@ bool menu_load_content(enum rarch_core_type type)
event_command(EVENT_CMD_HISTORY_INIT);
if (*global->path.fullpath || (menu && menu->load_no_content))
if (*fullpath || (menu && menu->load_no_content))
menu_push_to_history_playlist();
event_command(EVENT_CMD_VIDEO_SET_ASPECT_RATIO);

View File

@ -1769,12 +1769,15 @@ static int menu_displaylist_parse_horizontal_content_actions(menu_displaylist_in
const char *core_path = NULL;
const char *core_name = NULL;
const char *db_name = NULL;
char *fullpath = NULL;
if (!menu)
return -1;
rarch_main_ctl(RARCH_MAIN_CTL_GET_CONTENT_PATH, &fullpath);
if (global->inited.main && (global->inited.core.type != CORE_TYPE_DUMMY)
&& !strcmp(menu->deferred_path, global->path.fullpath))
&& !strcmp(menu->deferred_path, fullpath))
menu_displaylist_parse_load_content_settings(info);
else
menu_entries_push(info->list, "Run", "collection",

View File

@ -1162,7 +1162,10 @@ int rarch_main_init(int argc, char *argv[])
if (settings && (settings->multimedia.builtin_mediaplayer_enable ||
settings->multimedia.builtin_imageviewer_enable))
{
switch (rarch_path_is_media_type(global->path.fullpath))
char *fullpath = NULL;
rarch_main_ctl(RARCH_MAIN_CTL_GET_CONTENT_PATH, &fullpath);
switch (rarch_path_is_media_type(fullpath))
{
case RARCH_CONTENT_MOVIE:
case RARCH_CONTENT_MUSIC:
@ -1501,7 +1504,6 @@ void rarch_playlist_load_content(void *data, unsigned idx)
const char *core_path = NULL;
const char *path = NULL;
content_playlist_t *playlist = (content_playlist_t*)data;
settings_t *settings = config_get_ptr();
#ifdef HAVE_MENU
menu_handle_t *menu = menu_driver_get_ptr();
#endif
@ -1579,7 +1581,6 @@ int rarch_defer_core(core_info_list_t *core_info, const char *dir,
char new_core_path[PATH_MAX_LENGTH] = {0};
const core_info_t *info = NULL;
size_t supported = 0;
settings_t *settings = config_get_ptr();
global_t *global = global_get_ptr();
#ifdef HAVE_MENU
uint32_t menu_label_hash = msg_hash_calculate(menu_label);

View File

@ -325,6 +325,17 @@ bool rarch_main_ctl(enum rarch_main_ctl_state state, void *data)
strlcpy(settings->libretro, fullpath, sizeof(settings->libretro));
}
break;
case RARCH_MAIN_CTL_CLEAR_CONTENT_PATH:
*global->path.fullpath = '\0';
break;
case RARCH_MAIN_CTL_GET_CONTENT_PATH:
{
char **fullpath = (char**)data;
if (!fullpath)
return false;
*fullpath = (char*)global->path.fullpath;
}
break;
case RARCH_MAIN_CTL_SET_CONTENT_PATH:
{
const char *fullpath = (const char*)data;

View File

@ -38,7 +38,9 @@ enum rarch_main_ctl_state
{
RARCH_MAIN_CTL_IS_IDLE = 0,
RARCH_MAIN_CTL_SET_IDLE,
RARCH_MAIN_CTL_GET_CONTENT_PATH,
RARCH_MAIN_CTL_SET_CONTENT_PATH,
RARCH_MAIN_CTL_CLEAR_CONTENT_PATH,
RARCH_MAIN_CTL_SET_LIBRETRO_PATH,
RARCH_MAIN_CTL_IS_SLOWMOTION,
RARCH_MAIN_CTL_SET_SLOWMOTION,

View File

@ -300,7 +300,6 @@ extern void action_ok_push_quick_menu(void);
if (result == NSOKButton && panel.URL)
{
menu_handle_t *menu = menu_driver_get_ptr();
global_t *global = global_get_ptr();
settings_t *settings = config_get_ptr();
NSURL *url = (NSURL*)panel.URL;
NSString *__core = url.path;
@ -313,7 +312,7 @@ extern void action_ok_push_quick_menu(void);
if (menu->load_no_content && settings->core.set_supports_no_game_enable)
{
int ret = 0;
*global->path.fullpath = '\0';
rarch_main_ctl(RARCH_MAIN_CTL_CLEAR_CONTENT_PATH, NULL);
ret = menu_common_load_content(NULL, NULL, false, CORE_TYPE_PLAIN);
if (ret == -1)
action_ok_push_quick_menu();