mirror of
https://github.com/libretro/RetroArch
synced 2025-02-11 06:40:48 +00:00
Move code from menu_content.c to menu_cbs_ok.c
This commit is contained in:
parent
11576f1d99
commit
df17764673
@ -792,6 +792,134 @@ int generic_action_ok_displaylist_push(const char *path,
|
|||||||
return menu_cbs_exit();
|
return menu_cbs_exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* menu_content_load_from_playlist:
|
||||||
|
* @playlist : Playlist handle.
|
||||||
|
* @idx : Index in playlist.
|
||||||
|
*
|
||||||
|
* Initializes core and loads content based on playlist entry.
|
||||||
|
**/
|
||||||
|
static bool menu_content_playlist_load(menu_content_ctx_playlist_info_t *info)
|
||||||
|
{
|
||||||
|
const char *path = NULL;
|
||||||
|
playlist_t *playlist = (playlist_t*)info->data;
|
||||||
|
|
||||||
|
if (!playlist)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
playlist_get_index(playlist,
|
||||||
|
info->idx, &path, NULL, NULL, NULL, NULL, NULL);
|
||||||
|
|
||||||
|
if (string_is_empty(path))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
{
|
||||||
|
unsigned i;
|
||||||
|
bool valid_path = false;
|
||||||
|
char *path_check = NULL;
|
||||||
|
char *path_tolower = strdup(path);
|
||||||
|
|
||||||
|
for (i = 0; i < strlen(path_tolower); ++i)
|
||||||
|
path_tolower[i] = tolower(path_tolower[i]);
|
||||||
|
|
||||||
|
if (strstr(path_tolower, file_path_str(FILE_PATH_ZIP_EXTENSION)))
|
||||||
|
strstr(path_tolower, file_path_str(FILE_PATH_ZIP_EXTENSION))[4] = '\0';
|
||||||
|
else if (strstr(path_tolower, file_path_str(FILE_PATH_7Z_EXTENSION)))
|
||||||
|
strstr(path_tolower, file_path_str(FILE_PATH_7Z_EXTENSION))[3] = '\0';
|
||||||
|
|
||||||
|
path_check = (char *)
|
||||||
|
calloc(strlen(path_tolower) + 1, sizeof(char));
|
||||||
|
|
||||||
|
strncpy(path_check, path, strlen(path_tolower));
|
||||||
|
|
||||||
|
valid_path = path_is_valid(path_check);
|
||||||
|
|
||||||
|
free(path_tolower);
|
||||||
|
free(path_check);
|
||||||
|
|
||||||
|
if (!valid_path)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* menu_content_find_first_core:
|
||||||
|
* @core_info : Core info list handle.
|
||||||
|
* @dir : Directory. Gets joined with @path.
|
||||||
|
* @path : Path. Gets joined with @dir.
|
||||||
|
* @menu_label : Label identifier of menu setting.
|
||||||
|
* @s : Deferred core path. Will be filled in
|
||||||
|
* by function.
|
||||||
|
* @len : Size of @s.
|
||||||
|
*
|
||||||
|
* Gets deferred core.
|
||||||
|
*
|
||||||
|
* Returns: false if there are multiple deferred cores and a
|
||||||
|
* selection needs to be made from a list, otherwise
|
||||||
|
* returns true and fills in @s with path to core.
|
||||||
|
**/
|
||||||
|
static bool menu_content_find_first_core(menu_content_ctx_defer_info_t *def_info,
|
||||||
|
bool load_content_with_current_core,
|
||||||
|
char *new_core_path, size_t len)
|
||||||
|
{
|
||||||
|
const core_info_t *info = NULL;
|
||||||
|
size_t supported = 0;
|
||||||
|
core_info_list_t *core_info = (core_info_list_t*)def_info->data;
|
||||||
|
const char *default_info_dir = def_info->dir;
|
||||||
|
|
||||||
|
if (!string_is_empty(default_info_dir))
|
||||||
|
{
|
||||||
|
const char *default_info_path = def_info->path;
|
||||||
|
size_t default_info_length = def_info->len;
|
||||||
|
|
||||||
|
if (!string_is_empty(default_info_path))
|
||||||
|
fill_pathname_join(def_info->s,
|
||||||
|
default_info_dir, default_info_path,
|
||||||
|
default_info_length);
|
||||||
|
|
||||||
|
#ifdef HAVE_COMPRESSION
|
||||||
|
if (path_is_compressed_file(default_info_dir))
|
||||||
|
{
|
||||||
|
size_t len = strlen(default_info_dir);
|
||||||
|
/* In case of a compressed archive, we have to join with a hash */
|
||||||
|
/* We are going to write at the position of dir: */
|
||||||
|
retro_assert(len < strlen(def_info->s));
|
||||||
|
def_info->s[len] = '#';
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
if (core_info)
|
||||||
|
core_info_list_get_supported_cores(core_info,
|
||||||
|
def_info->s, &info,
|
||||||
|
&supported);
|
||||||
|
|
||||||
|
/* We started the menu with 'Load Content', we are
|
||||||
|
* going to use the current core to load this. */
|
||||||
|
if (load_content_with_current_core)
|
||||||
|
{
|
||||||
|
core_info_get_current_core((core_info_t**)&info);
|
||||||
|
if (info)
|
||||||
|
{
|
||||||
|
RARCH_LOG("Use the current core (%s) to load this content...\n",
|
||||||
|
info->path);
|
||||||
|
supported = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* There are multiple deferred cores and a
|
||||||
|
* selection needs to be made from a list, return 0. */
|
||||||
|
if (supported != 1)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (info)
|
||||||
|
strlcpy(new_core_path, info->path, len);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
static int file_load_with_detect_core_wrapper(
|
static int file_load_with_detect_core_wrapper(
|
||||||
enum msg_hash_enums enum_label_idx,
|
enum msg_hash_enums enum_label_idx,
|
||||||
enum msg_hash_enums enum_idx,
|
enum msg_hash_enums enum_idx,
|
||||||
|
@ -34,58 +34,6 @@
|
|||||||
#include "../playlist.h"
|
#include "../playlist.h"
|
||||||
#include "../verbosity.h"
|
#include "../verbosity.h"
|
||||||
|
|
||||||
/**
|
|
||||||
* menu_content_load_from_playlist:
|
|
||||||
* @playlist : Playlist handle.
|
|
||||||
* @idx : Index in playlist.
|
|
||||||
*
|
|
||||||
* Initializes core and loads content based on playlist entry.
|
|
||||||
**/
|
|
||||||
bool menu_content_playlist_load(menu_content_ctx_playlist_info_t *info)
|
|
||||||
{
|
|
||||||
const char *path = NULL;
|
|
||||||
playlist_t *playlist = (playlist_t*)info->data;
|
|
||||||
|
|
||||||
if (!playlist)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
playlist_get_index(playlist,
|
|
||||||
info->idx, &path, NULL, NULL, NULL, NULL, NULL);
|
|
||||||
|
|
||||||
if (string_is_empty(path))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
{
|
|
||||||
unsigned i;
|
|
||||||
bool valid_path = false;
|
|
||||||
char *path_check = NULL;
|
|
||||||
char *path_tolower = strdup(path);
|
|
||||||
|
|
||||||
for (i = 0; i < strlen(path_tolower); ++i)
|
|
||||||
path_tolower[i] = tolower(path_tolower[i]);
|
|
||||||
|
|
||||||
if (strstr(path_tolower, file_path_str(FILE_PATH_ZIP_EXTENSION)))
|
|
||||||
strstr(path_tolower, file_path_str(FILE_PATH_ZIP_EXTENSION))[4] = '\0';
|
|
||||||
else if (strstr(path_tolower, file_path_str(FILE_PATH_7Z_EXTENSION)))
|
|
||||||
strstr(path_tolower, file_path_str(FILE_PATH_7Z_EXTENSION))[3] = '\0';
|
|
||||||
|
|
||||||
path_check = (char *)
|
|
||||||
calloc(strlen(path_tolower) + 1, sizeof(char));
|
|
||||||
|
|
||||||
strncpy(path_check, path, strlen(path_tolower));
|
|
||||||
|
|
||||||
valid_path = path_is_valid(path_check);
|
|
||||||
|
|
||||||
free(path_tolower);
|
|
||||||
free(path_check);
|
|
||||||
|
|
||||||
if (!valid_path)
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool menu_content_playlist_find_associated_core(const char *path, char *s, size_t len)
|
bool menu_content_playlist_find_associated_core(const char *path, char *s, size_t len)
|
||||||
{
|
{
|
||||||
unsigned j;
|
unsigned j;
|
||||||
@ -119,79 +67,3 @@ bool menu_content_playlist_find_associated_core(const char *path, char *s, size_
|
|||||||
string_list_free(existing_core_paths);
|
string_list_free(existing_core_paths);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* menu_content_find_first_core:
|
|
||||||
* @core_info : Core info list handle.
|
|
||||||
* @dir : Directory. Gets joined with @path.
|
|
||||||
* @path : Path. Gets joined with @dir.
|
|
||||||
* @menu_label : Label identifier of menu setting.
|
|
||||||
* @s : Deferred core path. Will be filled in
|
|
||||||
* by function.
|
|
||||||
* @len : Size of @s.
|
|
||||||
*
|
|
||||||
* Gets deferred core.
|
|
||||||
*
|
|
||||||
* Returns: false if there are multiple deferred cores and a
|
|
||||||
* selection needs to be made from a list, otherwise
|
|
||||||
* returns true and fills in @s with path to core.
|
|
||||||
**/
|
|
||||||
bool menu_content_find_first_core(menu_content_ctx_defer_info_t *def_info,
|
|
||||||
bool load_content_with_current_core,
|
|
||||||
char *new_core_path, size_t len)
|
|
||||||
{
|
|
||||||
const core_info_t *info = NULL;
|
|
||||||
size_t supported = 0;
|
|
||||||
core_info_list_t *core_info = (core_info_list_t*)def_info->data;
|
|
||||||
const char *default_info_dir = def_info->dir;
|
|
||||||
|
|
||||||
if (!string_is_empty(default_info_dir))
|
|
||||||
{
|
|
||||||
const char *default_info_path = def_info->path;
|
|
||||||
size_t default_info_length = def_info->len;
|
|
||||||
|
|
||||||
if (!string_is_empty(default_info_path))
|
|
||||||
fill_pathname_join(def_info->s,
|
|
||||||
default_info_dir, default_info_path,
|
|
||||||
default_info_length);
|
|
||||||
|
|
||||||
#ifdef HAVE_COMPRESSION
|
|
||||||
if (path_is_compressed_file(default_info_dir))
|
|
||||||
{
|
|
||||||
size_t len = strlen(default_info_dir);
|
|
||||||
/* In case of a compressed archive, we have to join with a hash */
|
|
||||||
/* We are going to write at the position of dir: */
|
|
||||||
retro_assert(len < strlen(def_info->s));
|
|
||||||
def_info->s[len] = '#';
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
if (core_info)
|
|
||||||
core_info_list_get_supported_cores(core_info,
|
|
||||||
def_info->s, &info,
|
|
||||||
&supported);
|
|
||||||
|
|
||||||
/* We started the menu with 'Load Content', we are
|
|
||||||
* going to use the current core to load this. */
|
|
||||||
if (load_content_with_current_core)
|
|
||||||
{
|
|
||||||
core_info_get_current_core((core_info_t**)&info);
|
|
||||||
if (info)
|
|
||||||
{
|
|
||||||
RARCH_LOG("Use the current core (%s) to load this content...\n",
|
|
||||||
info->path);
|
|
||||||
supported = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* There are multiple deferred cores and a
|
|
||||||
* selection needs to be made from a list, return 0. */
|
|
||||||
if (supported != 1)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (info)
|
|
||||||
strlcpy(new_core_path, info->path, len);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
@ -40,22 +40,9 @@ typedef struct menu_content_ctx_defer_info
|
|||||||
size_t len;
|
size_t len;
|
||||||
} menu_content_ctx_defer_info_t;
|
} menu_content_ctx_defer_info_t;
|
||||||
|
|
||||||
/**
|
|
||||||
* menu_content_playlist_load:
|
|
||||||
* @playlist : Playlist handle.
|
|
||||||
* @idx : Index in playlist.
|
|
||||||
*
|
|
||||||
* Initializes core and loads content based on playlist entry.
|
|
||||||
**/
|
|
||||||
bool menu_content_playlist_load(menu_content_ctx_playlist_info_t *info);
|
|
||||||
|
|
||||||
bool menu_content_playlist_find_associated_core(const char *path,
|
bool menu_content_playlist_find_associated_core(const char *path,
|
||||||
char *s, size_t len);
|
char *s, size_t len);
|
||||||
|
|
||||||
bool menu_content_find_first_core(menu_content_ctx_defer_info_t *def_info,
|
|
||||||
bool load_content_with_current_core,
|
|
||||||
char *new_core_path, size_t len);
|
|
||||||
|
|
||||||
RETRO_END_DECLS
|
RETRO_END_DECLS
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user