From 01a3511445ca3f964a510fedd6fe49e4dcebb1d4 Mon Sep 17 00:00:00 2001 From: Eric Warmenhoven Date: Wed, 4 Jun 2025 14:50:38 -0400 Subject: [PATCH] iOS: rely on core info to re-find cores from old directory structure --- core_info.c | 2 +- menu/cbs/menu_cbs_ok.c | 2 -- playlist.c | 55 +++++++++++------------------------------- 3 files changed, 15 insertions(+), 44 deletions(-) diff --git a/core_info.c b/core_info.c index d9f561c116..0ef9a39150 100644 --- a/core_info.c +++ b/core_info.c @@ -1571,7 +1571,7 @@ static size_t core_info_get_file_id(const char *core_filename, && !string_is_equal(last_underscore, "_libretro")) { *last_underscore = '\0'; - _len = strlen(s); /* TODO/FIXME - make this unnecessary later on */ + _len = last_underscore - s; } return _len; } diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index eb22ab77ab..a71416ed09 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -2835,7 +2835,6 @@ static int action_ok_playlist_entry_collection(const char *path, } else { -#ifndef IOS core_info = playlist_entry_get_core_info(entry); if (core_info && !string_is_empty(core_info->path)) @@ -2843,7 +2842,6 @@ static int action_ok_playlist_entry_collection(const char *path, else /* Core path is invalid - just copy what we have * and hope for the best... */ -#endif { strlcpy(core_path, entry->core_path, sizeof(core_path)); playlist_resolve_path(PLAYLIST_LOAD, true, core_path, sizeof(core_path)); diff --git a/playlist.c b/playlist.c index 2bf69c3f3c..2c0068ee61 100644 --- a/playlist.c +++ b/playlist.c @@ -1144,58 +1144,31 @@ enum playlist_thumbnail_name_flags playlist_get_next_thumbnail_name_flag(playlis void playlist_resolve_path(enum playlist_file_mode mode, bool is_core, char *s, size_t len) { + bool resolve_symlinks = true; + #if IOS char tmp[PATH_MAX_LENGTH]; - int _len = 0; if (mode == PLAYLIST_LOAD) { - if ( is_core - && string_starts_with(s, ":/modules/") - && string_ends_with(s, ".dylib")) - { - /* iOS cores used to be packaged as .dylib files in the modules - * directory; App Store rules require turning them into Frameworks and - * putting them in the Frameworks directory. Because some playlists - * include the old core path, we'll translate it here. - */ - s[string_index_last_occurance(s, '.')] = '\0'; - if (string_ends_with(s, "_ios")) - s[string_index_last_occurance(s, '_')] = '\0'; - _len += strlcpy(tmp + _len, ":/Frameworks/", STRLEN_CONST(":/Frameworks/") + 1); - _len += strlcpy(tmp + _len, s + STRLEN_CONST(":/modules/"), sizeof(tmp) - _len); - /* iOS framework names, to quote Apple: - * "must contain only alphanumerics, dots, hyphens and must not end with a dot." - * - * Since core names include underscore, which is not allowed, but not dot, - * which is, we change underscore to dot. - */ - string_replace_all_chars(tmp, '_', '.'); - strlcpy(tmp + _len, ".framework", sizeof(tmp)); - fill_pathname_expand_special(s, tmp, len); - } - else - { - fill_pathname_expand_special(tmp, s, sizeof(tmp)); - strlcpy(s, tmp, len); - } + /* This is probably safe for all platforms, it should end up being just a + * lot of string copies without changing it */ + fill_pathname_expand_special(tmp, s, sizeof(tmp)); + strlcpy(s, tmp, len); } else { - /* iOS needs to call realpath here since the call - * above fails due to possibly buffer related issues. - * Try to expand the path to ensure that it gets saved - * correctly. The path can be abbreviated if saving to - * a playlist from another playlist (ex: content history to favorites) - */ - char tmp2[PATH_MAX_LENGTH]; + /* Try to expand the path to ensure that it gets saved correctly. The path + * can be abbreviated if saving to a playlist from another playlist (ex: + * content history to favorites). This is probably safe for all + * platforms */ fill_pathname_expand_special(tmp, s, sizeof(tmp)); - realpath(tmp, tmp2); - fill_pathname_abbreviate_special(s, tmp2, len); + path_resolve_realpath(tmp, sizeof(tmp), resolve_symlinks); + /* iOS requries this because the full path can change after app update; + * it's probably safe for all platforms... */ + fill_pathname_abbreviate_special(s, tmp, len); } #else - bool resolve_symlinks = true; - if (mode == PLAYLIST_LOAD) return;