2013-06-24 11:52:14 +00:00
|
|
|
/* RetroArch - A frontend for libretro.
|
2014-01-01 00:50:59 +00:00
|
|
|
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
2017-03-22 02:09:18 +00:00
|
|
|
* Copyright (C) 2011-2017 - Daniel De Matteis
|
2019-02-22 21:31:54 +00:00
|
|
|
* Copyright (C) 2016-2019 - Brad Parker
|
2016-10-10 08:49:09 +00:00
|
|
|
*
|
2013-06-24 11:52:14 +00:00
|
|
|
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
|
|
|
* of the GNU General Public License as published by the Free Software Found-
|
|
|
|
* ation, either version 3 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
|
|
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE. See the GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along with RetroArch.
|
|
|
|
* If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2016-09-08 04:07:43 +00:00
|
|
|
#include <compat/strl.h>
|
|
|
|
#include <string/stdstring.h>
|
2018-04-10 01:02:10 +00:00
|
|
|
#include <file/config_file.h>
|
2014-10-21 22:23:06 +00:00
|
|
|
#include <file/file_path.h>
|
2020-06-18 16:08:57 +00:00
|
|
|
#include <streams/file_stream.h>
|
2021-05-06 10:58:45 +00:00
|
|
|
#include <streams/interface_stream.h>
|
|
|
|
#include <formats/rjson.h>
|
2016-03-20 13:53:54 +00:00
|
|
|
#include <lists/dir_list.h>
|
2016-03-20 15:14:40 +00:00
|
|
|
#include <file/archive_file.h>
|
2015-09-04 19:11:00 +00:00
|
|
|
|
2016-09-08 04:07:43 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
2016-01-20 03:07:24 +00:00
|
|
|
|
2023-01-08 08:05:46 +00:00
|
|
|
#include "retroarch.h"
|
2021-05-06 10:58:45 +00:00
|
|
|
#include "verbosity.h"
|
2016-11-28 01:24:23 +00:00
|
|
|
|
2015-12-11 12:56:00 +00:00
|
|
|
#include "core_info.h"
|
2018-04-09 20:20:51 +00:00
|
|
|
#include "file_path_special.h"
|
2013-10-05 16:33:22 +00:00
|
|
|
|
2019-01-02 12:30:58 +00:00
|
|
|
#if defined(__WINRT__) || defined(WINAPI_FAMILY) && WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
|
2019-01-01 13:47:41 +00:00
|
|
|
#include "uwp/uwp_func.h"
|
|
|
|
#endif
|
|
|
|
|
2020-08-28 15:27:48 +00:00
|
|
|
#if defined(ANDROID)
|
|
|
|
#include "play_feature_delivery/play_feature_delivery.h"
|
|
|
|
#endif
|
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
/*************************/
|
|
|
|
/* Core Info Cache START */
|
|
|
|
/*************************/
|
|
|
|
|
2022-02-22 18:23:48 +00:00
|
|
|
#define CORE_INFO_CACHE_VERSION "1.2"
|
2021-05-06 10:58:45 +00:00
|
|
|
#define CORE_INFO_CACHE_DEFAULT_CAPACITY 8
|
|
|
|
|
2021-05-07 09:16:21 +00:00
|
|
|
/* TODO/FIXME: Apparently rzip compression is an issue on UWP */
|
|
|
|
#if defined(HAVE_ZLIB) && !(defined(__WINRT__) || defined(WINAPI_FAMILY) && WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP)
|
|
|
|
#define CORE_INFO_CACHE_COMPRESS
|
|
|
|
#endif
|
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
core_info_t *items;
|
|
|
|
size_t length;
|
|
|
|
size_t capacity;
|
2022-02-02 15:49:53 +00:00
|
|
|
char *version;
|
2021-05-06 10:58:45 +00:00
|
|
|
bool refresh;
|
|
|
|
} core_info_cache_list_t;
|
2021-05-04 14:01:17 +00:00
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
2021-05-06 10:58:45 +00:00
|
|
|
core_info_t *core_info;
|
|
|
|
core_info_cache_list_t *core_info_cache_list;
|
2021-05-04 14:01:17 +00:00
|
|
|
char **current_string_val;
|
|
|
|
struct string_list **current_string_list_val;
|
|
|
|
uint32_t *current_entry_uint_val;
|
|
|
|
bool *current_entry_bool_val;
|
|
|
|
unsigned array_depth;
|
|
|
|
unsigned object_depth;
|
2021-05-06 10:58:45 +00:00
|
|
|
bool to_core_file_id;
|
|
|
|
bool to_firmware;
|
2021-05-04 14:01:17 +00:00
|
|
|
} CCJSONContext;
|
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
/* Forward declarations */
|
|
|
|
static void core_info_free(core_info_t* info);
|
|
|
|
static uint32_t core_info_hash_string(const char *str);
|
2021-12-05 06:12:23 +00:00
|
|
|
#ifdef HAVE_CORE_INFO_CACHE
|
2021-05-06 10:58:45 +00:00
|
|
|
static core_info_cache_list_t *core_info_cache_list_new(void);
|
2021-12-05 06:12:23 +00:00
|
|
|
#endif
|
2021-09-20 13:43:57 +00:00
|
|
|
static void core_info_cache_add(core_info_cache_list_t *list,
|
|
|
|
core_info_t *info, bool transfer);
|
2019-07-24 02:44:45 +00:00
|
|
|
|
2021-09-20 13:43:57 +00:00
|
|
|
static core_info_state_t core_info_st = {
|
|
|
|
#ifdef HAVE_COMPRESSION
|
|
|
|
NULL,
|
|
|
|
#endif
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL
|
2021-09-20 13:54:07 +00:00
|
|
|
};
|
2021-09-20 13:43:27 +00:00
|
|
|
|
2021-11-23 04:13:36 +00:00
|
|
|
#ifdef HAVE_CORE_INFO_CACHE
|
2021-05-06 10:58:45 +00:00
|
|
|
/* JSON Handlers START */
|
2021-04-26 13:24:24 +00:00
|
|
|
|
2021-09-20 13:43:57 +00:00
|
|
|
static bool CCJSONObjectMemberHandler(void *context,
|
|
|
|
const char *pValue, size_t length)
|
2021-04-26 13:24:24 +00:00
|
|
|
{
|
2021-05-06 10:58:45 +00:00
|
|
|
CCJSONContext *pCtx = (CCJSONContext *)context;
|
2021-04-26 13:24:24 +00:00
|
|
|
|
2024-07-24 07:55:34 +00:00
|
|
|
if (length)
|
2021-05-06 10:58:45 +00:00
|
|
|
{
|
2024-07-24 07:55:34 +00:00
|
|
|
switch (pCtx->array_depth)
|
2021-05-06 10:58:45 +00:00
|
|
|
{
|
2024-07-24 07:55:34 +00:00
|
|
|
case 0:
|
|
|
|
if (pCtx->object_depth == 1)
|
2021-05-06 10:58:45 +00:00
|
|
|
{
|
2024-07-24 07:55:34 +00:00
|
|
|
pCtx->current_string_val = NULL;
|
|
|
|
|
|
|
|
if (string_is_equal(pValue, "version"))
|
|
|
|
pCtx->current_string_val = &pCtx->core_info_cache_list->version;
|
2021-05-06 10:58:45 +00:00
|
|
|
}
|
|
|
|
break;
|
2024-07-24 07:55:34 +00:00
|
|
|
case 1:
|
|
|
|
if (pCtx->object_depth == 2)
|
2021-05-06 10:58:45 +00:00
|
|
|
{
|
2024-07-24 07:55:34 +00:00
|
|
|
pCtx->current_string_val = NULL;
|
|
|
|
pCtx->current_string_list_val = NULL;
|
|
|
|
pCtx->current_entry_uint_val = NULL;
|
|
|
|
pCtx->current_entry_bool_val = NULL;
|
|
|
|
pCtx->to_core_file_id = false;
|
|
|
|
pCtx->to_firmware = false;
|
|
|
|
|
|
|
|
switch (pValue[0])
|
|
|
|
{
|
|
|
|
case 'a':
|
|
|
|
if (string_is_equal(pValue, "authors"))
|
|
|
|
{
|
|
|
|
pCtx->current_string_val = &pCtx->core_info->authors;
|
|
|
|
pCtx->current_string_list_val = &pCtx->core_info->authors_list;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'c':
|
|
|
|
if (string_is_equal(pValue, "categories"))
|
|
|
|
{
|
|
|
|
pCtx->current_string_val = &pCtx->core_info->categories;
|
|
|
|
pCtx->current_string_list_val = &pCtx->core_info->categories_list;
|
|
|
|
}
|
|
|
|
else if (string_is_equal(pValue, "core_name"))
|
|
|
|
pCtx->current_string_val = &pCtx->core_info->core_name;
|
|
|
|
else if (string_is_equal(pValue, "core_file_id"))
|
|
|
|
pCtx->to_core_file_id = true;
|
|
|
|
break;
|
|
|
|
case 'd':
|
|
|
|
if (string_is_equal(pValue, "display_name"))
|
|
|
|
pCtx->current_string_val = &pCtx->core_info->display_name;
|
|
|
|
else if (string_is_equal(pValue, "display_version"))
|
|
|
|
pCtx->current_string_val = &pCtx->core_info->display_version;
|
|
|
|
else if (string_is_equal(pValue, "databases"))
|
|
|
|
{
|
|
|
|
pCtx->current_string_val = &pCtx->core_info->databases;
|
|
|
|
pCtx->current_string_list_val = &pCtx->core_info->databases_list;
|
|
|
|
}
|
|
|
|
else if (string_is_equal(pValue, "description"))
|
|
|
|
pCtx->current_string_val = &pCtx->core_info->description;
|
|
|
|
else if (string_is_equal(pValue, "database_match_archive_member"))
|
|
|
|
pCtx->current_entry_bool_val = &pCtx->core_info->database_match_archive_member;
|
|
|
|
break;
|
|
|
|
case 'f':
|
|
|
|
if (string_is_equal(pValue, "firmware"))
|
|
|
|
pCtx->to_firmware = true;
|
|
|
|
break;
|
|
|
|
case 'h':
|
|
|
|
if (string_is_equal(pValue, "has_info"))
|
|
|
|
pCtx->current_entry_bool_val = &pCtx->core_info->has_info;
|
|
|
|
break;
|
|
|
|
case 'l':
|
|
|
|
if (string_is_equal(pValue, "licenses"))
|
|
|
|
{
|
|
|
|
pCtx->current_string_val = &pCtx->core_info->licenses;
|
|
|
|
pCtx->current_string_list_val = &pCtx->core_info->licenses_list;
|
|
|
|
}
|
|
|
|
else if (string_is_equal(pValue, "is_experimental"))
|
|
|
|
pCtx->current_entry_bool_val = &pCtx->core_info->is_experimental;
|
|
|
|
break;
|
|
|
|
case 'n':
|
|
|
|
if (string_is_equal(pValue, "notes"))
|
|
|
|
{
|
|
|
|
pCtx->current_string_val = &pCtx->core_info->notes;
|
|
|
|
pCtx->current_string_list_val = &pCtx->core_info->note_list;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'p':
|
|
|
|
if (string_is_equal(pValue, "permissions"))
|
|
|
|
{
|
|
|
|
pCtx->current_string_val = &pCtx->core_info->permissions;
|
|
|
|
pCtx->current_string_list_val = &pCtx->core_info->permissions_list;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'r':
|
|
|
|
if (string_is_equal(pValue, "required_hw_api"))
|
|
|
|
{
|
|
|
|
pCtx->current_string_val = &pCtx->core_info->required_hw_api;
|
|
|
|
pCtx->current_string_list_val = &pCtx->core_info->required_hw_api_list;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 's':
|
|
|
|
if (string_is_equal(pValue, "system_manufacturer"))
|
|
|
|
pCtx->current_string_val = &pCtx->core_info->system_manufacturer;
|
|
|
|
else if (string_is_equal(pValue, "systemname"))
|
|
|
|
pCtx->current_string_val = &pCtx->core_info->systemname;
|
|
|
|
else if (string_is_equal(pValue, "system_id"))
|
|
|
|
pCtx->current_string_val = &pCtx->core_info->system_id;
|
|
|
|
else if (string_is_equal(pValue, "supported_extensions"))
|
|
|
|
{
|
|
|
|
pCtx->current_string_val = &pCtx->core_info->supported_extensions;
|
|
|
|
pCtx->current_string_list_val = &pCtx->core_info->supported_extensions_list;
|
|
|
|
}
|
|
|
|
else if (string_is_equal(pValue, "supports_no_game"))
|
|
|
|
pCtx->current_entry_bool_val = &pCtx->core_info->supports_no_game;
|
|
|
|
else if (string_is_equal(pValue, "single_purpose"))
|
|
|
|
pCtx->current_entry_bool_val = &pCtx->core_info->single_purpose;
|
|
|
|
else if (string_is_equal(pValue, "savestate_support_level"))
|
|
|
|
pCtx->current_entry_uint_val = &pCtx->core_info->savestate_support_level;
|
|
|
|
break;
|
|
|
|
}
|
2021-05-06 10:58:45 +00:00
|
|
|
}
|
2024-07-24 07:55:34 +00:00
|
|
|
else if (pCtx->object_depth == 3)
|
2021-05-06 10:58:45 +00:00
|
|
|
{
|
2024-07-24 07:55:34 +00:00
|
|
|
pCtx->current_string_val = NULL;
|
|
|
|
pCtx->current_entry_uint_val = NULL;
|
|
|
|
|
|
|
|
if (pCtx->to_core_file_id)
|
|
|
|
{
|
|
|
|
if (string_is_equal(pValue, "str"))
|
|
|
|
pCtx->current_string_val = &pCtx->core_info->core_file_id.str;
|
|
|
|
else if (string_is_equal(pValue, "hash"))
|
|
|
|
pCtx->current_entry_uint_val = &pCtx->core_info->core_file_id.hash;
|
|
|
|
}
|
2021-05-06 10:58:45 +00:00
|
|
|
}
|
|
|
|
break;
|
2024-07-24 07:55:34 +00:00
|
|
|
case 2:
|
|
|
|
if (pCtx->object_depth == 3)
|
2021-05-06 10:58:45 +00:00
|
|
|
{
|
2024-07-24 07:55:34 +00:00
|
|
|
pCtx->current_string_val = NULL;
|
|
|
|
pCtx->current_entry_bool_val = NULL;
|
|
|
|
|
|
|
|
if (pCtx->to_firmware && (pCtx->core_info->firmware_count > 0))
|
|
|
|
{
|
|
|
|
size_t firmware_idx = pCtx->core_info->firmware_count - 1;
|
|
|
|
|
|
|
|
if (string_is_equal(pValue, "path"))
|
|
|
|
pCtx->current_string_val = &pCtx->core_info->firmware[firmware_idx].path;
|
|
|
|
else if (string_is_equal(pValue, "desc"))
|
|
|
|
pCtx->current_string_val = &pCtx->core_info->firmware[firmware_idx].desc;
|
|
|
|
else if (string_is_equal(pValue, "optional"))
|
|
|
|
pCtx->current_entry_bool_val = &pCtx->core_info->firmware[firmware_idx].optional;
|
|
|
|
}
|
2021-05-06 10:58:45 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2021-04-26 13:24:24 +00:00
|
|
|
|
2022-02-02 15:49:53 +00:00
|
|
|
}
|
2021-04-26 13:24:24 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
return true;
|
2021-04-26 13:24:24 +00:00
|
|
|
}
|
|
|
|
|
2021-09-20 13:43:57 +00:00
|
|
|
static bool CCJSONStringHandler(void *context,
|
|
|
|
const char *pValue, size_t length)
|
2021-04-26 13:24:24 +00:00
|
|
|
{
|
2021-05-06 10:58:45 +00:00
|
|
|
CCJSONContext *pCtx = (CCJSONContext*)context;
|
2021-04-26 13:24:24 +00:00
|
|
|
|
2024-06-16 17:42:32 +00:00
|
|
|
if ( pCtx->current_string_val
|
|
|
|
&& length
|
2021-11-23 04:05:09 +00:00
|
|
|
&& !string_is_empty(pValue))
|
2021-04-26 13:24:24 +00:00
|
|
|
{
|
2021-05-06 10:58:45 +00:00
|
|
|
if (*pCtx->current_string_val)
|
|
|
|
free(*pCtx->current_string_val);
|
|
|
|
*pCtx->current_string_val = strdup(pValue);
|
2021-04-26 13:24:24 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
if (pCtx->current_string_list_val)
|
|
|
|
{
|
|
|
|
if (*pCtx->current_string_list_val)
|
|
|
|
string_list_free(*pCtx->current_string_list_val);
|
2024-06-16 17:42:32 +00:00
|
|
|
*pCtx->current_string_list_val =
|
2021-11-23 04:05:09 +00:00
|
|
|
string_split(*pCtx->current_string_val, "|");
|
2021-05-06 10:58:45 +00:00
|
|
|
}
|
2021-04-26 13:24:24 +00:00
|
|
|
}
|
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
pCtx->current_string_val = NULL;
|
|
|
|
pCtx->current_string_list_val = NULL;
|
|
|
|
|
|
|
|
return true;
|
2021-04-26 13:24:24 +00:00
|
|
|
}
|
|
|
|
|
2021-09-20 13:43:57 +00:00
|
|
|
static bool CCJSONNumberHandler(void *context,
|
|
|
|
const char *pValue, size_t length)
|
2021-04-26 13:24:24 +00:00
|
|
|
{
|
2022-12-05 11:56:55 +00:00
|
|
|
CCJSONContext *pCtx = (CCJSONContext*)context;
|
2021-04-26 13:24:24 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
if (pCtx->current_entry_uint_val)
|
|
|
|
*pCtx->current_entry_uint_val = string_to_unsigned(pValue);
|
2021-04-26 13:24:24 +00:00
|
|
|
|
2022-12-05 11:56:55 +00:00
|
|
|
pCtx->current_entry_uint_val = NULL;
|
2021-04-26 13:24:24 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
return true;
|
|
|
|
}
|
2021-04-26 13:24:24 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
static bool CCJSONBoolHandler(void *context, bool value)
|
|
|
|
{
|
2022-12-05 11:56:55 +00:00
|
|
|
CCJSONContext *pCtx = (CCJSONContext *)context;
|
2021-04-26 13:24:24 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
if (pCtx->current_entry_bool_val)
|
|
|
|
*pCtx->current_entry_bool_val = value;
|
2021-04-26 13:24:24 +00:00
|
|
|
|
2021-11-23 04:05:09 +00:00
|
|
|
pCtx->current_entry_bool_val = NULL;
|
2021-04-26 13:24:24 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
return true;
|
|
|
|
}
|
2021-04-26 13:24:24 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
static bool CCJSONStartObjectHandler(void *context)
|
|
|
|
{
|
|
|
|
CCJSONContext *pCtx = (CCJSONContext*)context;
|
2021-04-26 13:24:24 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
pCtx->object_depth++;
|
2021-04-26 13:24:24 +00:00
|
|
|
|
2024-07-24 07:55:34 +00:00
|
|
|
switch (pCtx->array_depth)
|
2021-05-06 10:58:45 +00:00
|
|
|
{
|
2024-07-24 07:55:34 +00:00
|
|
|
case 0:
|
|
|
|
if (pCtx->object_depth == 1)
|
|
|
|
{
|
|
|
|
if (pCtx->core_info_cache_list)
|
|
|
|
return false;
|
|
|
|
if (!(pCtx->core_info_cache_list = core_info_cache_list_new()))
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
if (pCtx->object_depth == 2)
|
|
|
|
{
|
|
|
|
if (pCtx->core_info)
|
|
|
|
{
|
|
|
|
core_info_free(pCtx->core_info);
|
|
|
|
free(pCtx->core_info);
|
|
|
|
pCtx->core_info = NULL;
|
|
|
|
}
|
2022-02-02 15:49:53 +00:00
|
|
|
|
2024-07-24 07:55:34 +00:00
|
|
|
if (!(pCtx->core_info = (core_info_t*)calloc(1, sizeof(core_info_t))))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
/* Assume all cores have 'full' savestate support
|
|
|
|
* by default */
|
|
|
|
pCtx->core_info->savestate_support_level =
|
|
|
|
CORE_INFO_SAVESTATE_DETERMINISTIC;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
if (pCtx->object_depth == 3 && pCtx->to_firmware)
|
|
|
|
{
|
|
|
|
size_t new_idx = pCtx->core_info->firmware_count;
|
|
|
|
core_info_firmware_t *tmp = (core_info_firmware_t*)
|
2021-05-06 10:58:45 +00:00
|
|
|
realloc(pCtx->core_info->firmware,
|
2024-07-24 07:55:34 +00:00
|
|
|
(pCtx->core_info->firmware_count + 1)
|
2021-11-23 04:05:09 +00:00
|
|
|
* sizeof(core_info_firmware_t));
|
2021-04-26 13:24:24 +00:00
|
|
|
|
2024-07-24 07:55:34 +00:00
|
|
|
if (!tmp)
|
|
|
|
return false;
|
2021-05-06 10:58:45 +00:00
|
|
|
|
2024-07-24 07:55:34 +00:00
|
|
|
tmp[new_idx].path = NULL;
|
|
|
|
tmp[new_idx].desc = NULL;
|
|
|
|
tmp[new_idx].missing = false;
|
|
|
|
tmp[new_idx].optional = false;
|
2021-05-06 10:58:45 +00:00
|
|
|
|
2024-07-24 07:55:34 +00:00
|
|
|
pCtx->core_info->firmware = tmp;
|
|
|
|
pCtx->core_info->firmware_count++;
|
|
|
|
}
|
|
|
|
break;
|
2021-05-06 10:58:45 +00:00
|
|
|
}
|
|
|
|
|
2024-07-24 07:55:34 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
return true;
|
2021-04-26 13:24:24 +00:00
|
|
|
}
|
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
static bool CCJSONEndObjectHandler(void *context)
|
2021-04-26 13:24:24 +00:00
|
|
|
{
|
2021-05-06 10:58:45 +00:00
|
|
|
CCJSONContext *pCtx = (CCJSONContext*)context;
|
2021-04-26 13:24:24 +00:00
|
|
|
|
2024-07-24 07:55:34 +00:00
|
|
|
if (pCtx->array_depth == 1)
|
2021-05-06 10:58:45 +00:00
|
|
|
{
|
2024-07-24 07:55:34 +00:00
|
|
|
switch (pCtx->object_depth)
|
|
|
|
{
|
|
|
|
case 2:
|
|
|
|
if (pCtx->core_info)
|
|
|
|
{
|
|
|
|
core_info_cache_add(
|
|
|
|
pCtx->core_info_cache_list, pCtx->core_info, true);
|
|
|
|
free(pCtx->core_info);
|
|
|
|
pCtx->core_info = NULL;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
pCtx->to_core_file_id = false;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2021-05-06 10:58:45 +00:00
|
|
|
}
|
2021-04-26 13:24:24 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
pCtx->object_depth--;
|
2021-04-26 13:24:24 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
return true;
|
|
|
|
}
|
2021-04-26 13:24:24 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
static bool CCJSONStartArrayHandler(void *context)
|
|
|
|
{
|
|
|
|
CCJSONContext *pCtx = (CCJSONContext*)context;
|
|
|
|
pCtx->array_depth++;
|
|
|
|
return true;
|
2021-04-26 13:24:24 +00:00
|
|
|
}
|
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
static bool CCJSONEndArrayHandler(void *context)
|
2021-04-26 13:24:24 +00:00
|
|
|
{
|
2021-05-06 10:58:45 +00:00
|
|
|
CCJSONContext *pCtx = (CCJSONContext*)context;
|
2021-04-26 13:24:24 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
if ((pCtx->object_depth == 2) && (pCtx->array_depth == 2))
|
|
|
|
pCtx->to_firmware = false;
|
2021-04-26 13:24:24 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
pCtx->array_depth--;
|
2021-04-26 13:24:24 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
return true;
|
|
|
|
}
|
2021-04-26 13:24:24 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
/* JSON Handlers END */
|
2021-11-23 04:13:36 +00:00
|
|
|
#endif
|
2021-04-26 13:24:24 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
/* Note: 'dst' must be zero initialised, or memory
|
|
|
|
* leaks will occur */
|
|
|
|
static void core_info_copy(core_info_t *src, core_info_t *dst)
|
|
|
|
{
|
|
|
|
dst->path = src->path ? strdup(src->path) : NULL;
|
|
|
|
dst->display_name = src->display_name ? strdup(src->display_name) : NULL;
|
|
|
|
dst->display_version = src->display_version ? strdup(src->display_version) : NULL;
|
|
|
|
dst->core_name = src->core_name ? strdup(src->core_name) : NULL;
|
|
|
|
dst->system_manufacturer = src->system_manufacturer ? strdup(src->system_manufacturer) : NULL;
|
|
|
|
dst->systemname = src->systemname ? strdup(src->systemname) : NULL;
|
|
|
|
dst->system_id = src->system_id ? strdup(src->system_id) : NULL;
|
|
|
|
dst->supported_extensions = src->supported_extensions ? strdup(src->supported_extensions) : NULL;
|
|
|
|
dst->authors = src->authors ? strdup(src->authors) : NULL;
|
|
|
|
dst->permissions = src->permissions ? strdup(src->permissions) : NULL;
|
|
|
|
dst->licenses = src->licenses ? strdup(src->licenses) : NULL;
|
|
|
|
dst->categories = src->categories ? strdup(src->categories) : NULL;
|
|
|
|
dst->databases = src->databases ? strdup(src->databases) : NULL;
|
|
|
|
dst->notes = src->notes ? strdup(src->notes) : NULL;
|
|
|
|
dst->required_hw_api = src->required_hw_api ? strdup(src->required_hw_api) : NULL;
|
|
|
|
dst->description = src->description ? strdup(src->description) : NULL;
|
|
|
|
|
|
|
|
dst->categories_list = src->categories_list ? string_list_clone(src->categories_list) : NULL;
|
|
|
|
dst->databases_list = src->databases_list ? string_list_clone(src->databases_list) : NULL;
|
|
|
|
dst->note_list = src->note_list ? string_list_clone(src->note_list) : NULL;
|
|
|
|
dst->supported_extensions_list = src->supported_extensions_list ? string_list_clone(src->supported_extensions_list) : NULL;
|
|
|
|
dst->authors_list = src->authors_list ? string_list_clone(src->authors_list) : NULL;
|
|
|
|
dst->permissions_list = src->permissions_list ? string_list_clone(src->permissions_list) : NULL;
|
|
|
|
dst->licenses_list = src->licenses_list ? string_list_clone(src->licenses_list) : NULL;
|
|
|
|
dst->required_hw_api_list = src->required_hw_api_list ? string_list_clone(src->required_hw_api_list) : NULL;
|
2021-04-26 13:24:24 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
if (src->firmware_count > 0)
|
2021-04-26 13:24:24 +00:00
|
|
|
{
|
2021-05-06 10:58:45 +00:00
|
|
|
dst->firmware = (core_info_firmware_t*)calloc(src->firmware_count,
|
|
|
|
sizeof(core_info_firmware_t));
|
2021-04-26 13:24:24 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
if (dst->firmware)
|
|
|
|
{
|
|
|
|
size_t i;
|
2021-04-26 13:24:24 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
dst->firmware_count = src->firmware_count;
|
2021-04-26 13:24:24 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
for (i = 0; i < src->firmware_count; i++)
|
|
|
|
{
|
|
|
|
dst->firmware[i].path = src->firmware[i].path ? strdup(src->firmware[i].path) : NULL;
|
|
|
|
dst->firmware[i].desc = src->firmware[i].desc ? strdup(src->firmware[i].desc) : NULL;
|
|
|
|
dst->firmware[i].missing = src->firmware[i].missing;
|
|
|
|
dst->firmware[i].optional = src->firmware[i].optional;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
dst->firmware_count = 0;
|
2021-04-26 13:24:24 +00:00
|
|
|
}
|
|
|
|
|
2024-06-16 17:42:32 +00:00
|
|
|
dst->core_file_id.str = src->core_file_id.str
|
2021-11-23 04:05:09 +00:00
|
|
|
? strdup(src->core_file_id.str) : NULL;
|
|
|
|
dst->core_file_id.hash = src->core_file_id.hash;
|
2021-04-26 13:24:24 +00:00
|
|
|
|
2022-02-02 15:49:53 +00:00
|
|
|
dst->savestate_support_level = src->savestate_support_level;
|
2021-05-06 10:58:45 +00:00
|
|
|
dst->has_info = src->has_info;
|
|
|
|
dst->supports_no_game = src->supports_no_game;
|
2022-02-22 18:23:48 +00:00
|
|
|
dst->single_purpose = src->single_purpose;
|
2021-05-06 10:58:45 +00:00
|
|
|
dst->database_match_archive_member = src->database_match_archive_member;
|
|
|
|
dst->is_experimental = src->is_experimental;
|
|
|
|
dst->is_locked = src->is_locked;
|
2022-03-09 16:49:16 +00:00
|
|
|
dst->is_standalone_exempt = src->is_standalone_exempt;
|
2021-05-06 10:58:45 +00:00
|
|
|
dst->is_installed = src->is_installed;
|
|
|
|
}
|
2021-04-26 13:24:24 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
/* Like core_info_copy, but transfers 'ownership'
|
|
|
|
* of internal objects/data structures from 'src'
|
|
|
|
* to 'dst' */
|
|
|
|
static void core_info_transfer(core_info_t *src, core_info_t *dst)
|
|
|
|
{
|
|
|
|
dst->path = src->path;
|
|
|
|
src->path = NULL;
|
2021-04-26 13:24:24 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
dst->display_name = src->display_name;
|
|
|
|
src->display_name = NULL;
|
2021-04-26 13:24:24 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
dst->display_version = src->display_version;
|
|
|
|
src->display_version = NULL;
|
2021-04-26 13:24:24 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
dst->core_name = src->core_name;
|
|
|
|
src->core_name = NULL;
|
2021-04-26 13:24:24 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
dst->system_manufacturer = src->system_manufacturer;
|
|
|
|
src->system_manufacturer = NULL;
|
2021-04-26 13:24:24 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
dst->systemname = src->systemname;
|
|
|
|
src->systemname = NULL;
|
2021-04-26 13:24:24 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
dst->system_id = src->system_id;
|
|
|
|
src->system_id = NULL;
|
2021-04-26 13:24:24 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
dst->supported_extensions = src->supported_extensions;
|
|
|
|
src->supported_extensions = NULL;
|
2021-04-26 13:24:24 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
dst->authors = src->authors;
|
|
|
|
src->authors = NULL;
|
2021-04-26 13:24:24 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
dst->permissions = src->permissions;
|
|
|
|
src->permissions = NULL;
|
2021-04-26 13:24:24 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
dst->licenses = src->licenses;
|
|
|
|
src->licenses = NULL;
|
2021-04-26 13:24:24 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
dst->categories = src->categories;
|
|
|
|
src->categories = NULL;
|
2021-04-26 13:24:24 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
dst->databases = src->databases;
|
|
|
|
src->databases = NULL;
|
2021-04-26 13:24:24 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
dst->notes = src->notes;
|
|
|
|
src->notes = NULL;
|
2021-04-26 13:24:24 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
dst->required_hw_api = src->required_hw_api;
|
|
|
|
src->required_hw_api = NULL;
|
2021-04-26 13:24:24 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
dst->description = src->description;
|
|
|
|
src->description = NULL;
|
2021-04-26 13:24:24 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
dst->categories_list = src->categories_list;
|
|
|
|
src->categories_list = NULL;
|
2021-04-26 13:24:24 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
dst->databases_list = src->databases_list;
|
|
|
|
src->databases_list = NULL;
|
2021-04-26 13:24:24 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
dst->note_list = src->note_list;
|
|
|
|
src->note_list = NULL;
|
2021-04-26 13:24:24 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
dst->supported_extensions_list = src->supported_extensions_list;
|
|
|
|
src->supported_extensions_list = NULL;
|
2021-04-26 13:24:24 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
dst->authors_list = src->authors_list;
|
|
|
|
src->authors_list = NULL;
|
2021-04-26 13:24:24 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
dst->permissions_list = src->permissions_list;
|
|
|
|
src->permissions_list = NULL;
|
2021-04-26 13:24:24 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
dst->licenses_list = src->licenses_list;
|
|
|
|
src->licenses_list = NULL;
|
2021-04-26 13:24:24 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
dst->required_hw_api_list = src->required_hw_api_list;
|
|
|
|
src->required_hw_api_list = NULL;
|
2021-04-26 13:24:24 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
dst->firmware = src->firmware;
|
|
|
|
dst->firmware_count = src->firmware_count;
|
|
|
|
src->firmware = NULL;
|
|
|
|
src->firmware_count = 0;
|
2021-04-26 13:24:24 +00:00
|
|
|
|
2021-11-23 04:05:09 +00:00
|
|
|
dst->core_file_id.str = src->core_file_id.str;
|
|
|
|
src->core_file_id.str = NULL;
|
|
|
|
dst->core_file_id.hash = src->core_file_id.hash;
|
2021-04-26 13:24:24 +00:00
|
|
|
|
2022-02-02 15:49:53 +00:00
|
|
|
dst->savestate_support_level = src->savestate_support_level;
|
2021-05-06 10:58:45 +00:00
|
|
|
dst->has_info = src->has_info;
|
|
|
|
dst->supports_no_game = src->supports_no_game;
|
2022-02-22 18:23:48 +00:00
|
|
|
dst->single_purpose = src->single_purpose;
|
2021-05-06 10:58:45 +00:00
|
|
|
dst->database_match_archive_member = src->database_match_archive_member;
|
|
|
|
dst->is_experimental = src->is_experimental;
|
|
|
|
dst->is_locked = src->is_locked;
|
2022-03-09 16:49:16 +00:00
|
|
|
dst->is_standalone_exempt = src->is_standalone_exempt;
|
2021-05-06 10:58:45 +00:00
|
|
|
dst->is_installed = src->is_installed;
|
2021-04-26 13:24:24 +00:00
|
|
|
}
|
|
|
|
|
2021-11-23 04:05:09 +00:00
|
|
|
static void core_info_cache_list_free(
|
|
|
|
core_info_cache_list_t *core_info_cache_list)
|
2013-11-21 22:48:31 +00:00
|
|
|
{
|
2021-05-06 10:58:45 +00:00
|
|
|
size_t i;
|
2019-05-10 06:31:18 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
if (!core_info_cache_list)
|
2019-05-10 06:31:18 +00:00
|
|
|
return;
|
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
for (i = 0; i < core_info_cache_list->length; i++)
|
2013-11-21 22:48:31 +00:00
|
|
|
{
|
2021-05-06 10:58:45 +00:00
|
|
|
core_info_t* info = (core_info_t*)&core_info_cache_list->items[i];
|
|
|
|
core_info_free(info);
|
2013-11-21 22:48:31 +00:00
|
|
|
}
|
2021-05-06 10:58:45 +00:00
|
|
|
|
|
|
|
free(core_info_cache_list->items);
|
2022-02-02 15:49:53 +00:00
|
|
|
|
|
|
|
if (core_info_cache_list->version)
|
|
|
|
free(core_info_cache_list->version);
|
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
free(core_info_cache_list);
|
2013-11-21 22:48:31 +00:00
|
|
|
}
|
|
|
|
|
2021-11-23 04:05:09 +00:00
|
|
|
static core_info_t *core_info_cache_find(
|
|
|
|
core_info_cache_list_t *list, char *core_file_id)
|
2016-02-07 11:51:45 +00:00
|
|
|
{
|
2021-05-06 10:58:45 +00:00
|
|
|
uint32_t hash;
|
2021-05-04 14:01:17 +00:00
|
|
|
size_t i;
|
2016-02-07 11:51:45 +00:00
|
|
|
|
2022-12-05 11:56:55 +00:00
|
|
|
if ( !list
|
|
|
|
|| string_is_empty(core_file_id))
|
2021-05-06 10:58:45 +00:00
|
|
|
return NULL;
|
2016-02-07 11:51:45 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
hash = core_info_hash_string(core_file_id);
|
|
|
|
|
|
|
|
for (i = 0; i < list->length; i++)
|
2016-02-07 11:51:45 +00:00
|
|
|
{
|
2021-05-06 10:58:45 +00:00
|
|
|
core_info_t *info = (core_info_t*)&list->items[i];
|
|
|
|
|
|
|
|
if (!info)
|
|
|
|
continue;
|
|
|
|
|
2022-12-05 11:56:55 +00:00
|
|
|
if ( (info->core_file_id.hash == hash)
|
|
|
|
&& string_is_equal(info->core_file_id.str, core_file_id))
|
2021-05-06 10:58:45 +00:00
|
|
|
{
|
|
|
|
info->is_installed = true;
|
|
|
|
return info;
|
|
|
|
}
|
2016-02-07 11:51:45 +00:00
|
|
|
}
|
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
return NULL;
|
2016-02-07 11:51:45 +00:00
|
|
|
}
|
|
|
|
|
2021-11-23 04:05:09 +00:00
|
|
|
static void core_info_cache_add(
|
|
|
|
core_info_cache_list_t *list, core_info_t *info,
|
2021-05-06 10:58:45 +00:00
|
|
|
bool transfer)
|
2021-05-04 14:01:17 +00:00
|
|
|
{
|
2021-05-06 10:58:45 +00:00
|
|
|
core_info_t *info_cache = NULL;
|
2021-05-04 14:01:17 +00:00
|
|
|
|
2021-11-23 04:05:09 +00:00
|
|
|
if ( !list
|
|
|
|
|| !info
|
|
|
|
|| (info->core_file_id.hash == 0)
|
|
|
|
|| string_is_empty(info->core_file_id.str))
|
2021-05-04 14:01:17 +00:00
|
|
|
return;
|
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
if (list->length >= list->capacity)
|
2021-05-04 14:01:17 +00:00
|
|
|
{
|
2021-05-06 10:58:45 +00:00
|
|
|
size_t prev_capacity = list->capacity;
|
|
|
|
core_info_t *items_tmp = (core_info_t*)realloc(list->items,
|
|
|
|
(list->capacity << 1) * sizeof(core_info_t));
|
|
|
|
|
|
|
|
if (!items_tmp)
|
|
|
|
return;
|
|
|
|
|
2022-12-05 11:56:55 +00:00
|
|
|
list->capacity = list->capacity << 1;
|
|
|
|
list->items = items_tmp;
|
2021-05-06 10:58:45 +00:00
|
|
|
|
|
|
|
memset(&list->items[prev_capacity], 0,
|
|
|
|
(list->capacity - prev_capacity) * sizeof(core_info_t));
|
2021-05-04 14:01:17 +00:00
|
|
|
}
|
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
info_cache = (core_info_t*)&list->items[list->length];
|
|
|
|
|
|
|
|
if (transfer)
|
|
|
|
core_info_transfer(info, info_cache);
|
|
|
|
else
|
|
|
|
core_info_copy(info, info_cache);
|
|
|
|
|
|
|
|
list->length++;
|
2021-05-04 14:01:17 +00:00
|
|
|
}
|
|
|
|
|
2021-11-23 04:05:09 +00:00
|
|
|
#ifdef HAVE_CORE_INFO_CACHE
|
2021-12-05 06:12:23 +00:00
|
|
|
static core_info_cache_list_t *core_info_cache_list_new(void)
|
|
|
|
{
|
2024-06-16 17:42:32 +00:00
|
|
|
core_info_cache_list_t *core_info_cache_list =
|
2021-12-05 06:12:23 +00:00
|
|
|
(core_info_cache_list_t *)malloc(sizeof(*core_info_cache_list));
|
|
|
|
if (!core_info_cache_list)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
core_info_cache_list->length = 0;
|
|
|
|
core_info_cache_list->items = (core_info_t *)
|
|
|
|
calloc(CORE_INFO_CACHE_DEFAULT_CAPACITY,
|
|
|
|
sizeof(core_info_t));
|
|
|
|
|
|
|
|
if (!core_info_cache_list->items)
|
|
|
|
{
|
|
|
|
core_info_cache_list_free(core_info_cache_list);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
core_info_cache_list->capacity = CORE_INFO_CACHE_DEFAULT_CAPACITY;
|
|
|
|
core_info_cache_list->refresh = false;
|
2022-02-02 15:49:53 +00:00
|
|
|
core_info_cache_list->version = NULL;
|
2021-12-05 06:12:23 +00:00
|
|
|
|
|
|
|
return core_info_cache_list;
|
|
|
|
}
|
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
static core_info_cache_list_t *core_info_cache_read(const char *info_dir)
|
2013-06-24 01:18:23 +00:00
|
|
|
{
|
2021-05-06 10:58:45 +00:00
|
|
|
intfstream_t *file = NULL;
|
|
|
|
rjson_t *parser = NULL;
|
|
|
|
CCJSONContext context = {0};
|
2021-05-04 14:01:17 +00:00
|
|
|
core_info_cache_list_t *core_info_cache_list = NULL;
|
2021-05-06 10:58:45 +00:00
|
|
|
char file_path[PATH_MAX_LENGTH];
|
2020-08-23 23:02:35 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
/* Check whether a 'force refresh' file
|
|
|
|
* is present */
|
|
|
|
if (string_is_empty(info_dir))
|
2021-11-23 04:05:09 +00:00
|
|
|
strlcpy(file_path,
|
|
|
|
FILE_PATH_CORE_INFO_CACHE_REFRESH, sizeof(file_path));
|
2021-05-06 10:58:45 +00:00
|
|
|
else
|
2022-08-04 12:18:11 +00:00
|
|
|
fill_pathname_join_special(file_path,
|
2021-11-23 04:05:09 +00:00
|
|
|
info_dir, FILE_PATH_CORE_INFO_CACHE_REFRESH,
|
2021-05-06 10:58:45 +00:00
|
|
|
sizeof(file_path));
|
2019-01-01 13:47:41 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
if (path_is_valid(file_path))
|
|
|
|
return core_info_cache_list_new();
|
2019-01-01 13:47:41 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
/* Open info cache file */
|
|
|
|
if (string_is_empty(info_dir))
|
|
|
|
strlcpy(file_path, FILE_PATH_CORE_INFO_CACHE, sizeof(file_path));
|
|
|
|
else
|
2022-08-04 12:18:11 +00:00
|
|
|
fill_pathname_join_special(file_path, info_dir,
|
|
|
|
FILE_PATH_CORE_INFO_CACHE,
|
2021-05-06 10:58:45 +00:00
|
|
|
sizeof(file_path));
|
2020-06-29 18:14:14 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
#if defined(HAVE_ZLIB)
|
|
|
|
file = intfstream_open_rzip_file(file_path,
|
|
|
|
RETRO_VFS_FILE_ACCESS_READ);
|
|
|
|
#else
|
|
|
|
file = intfstream_open_file(file_path,
|
|
|
|
RETRO_VFS_FILE_ACCESS_READ,
|
|
|
|
RETRO_VFS_FILE_ACCESS_HINT_NONE);
|
|
|
|
#endif
|
2020-06-29 18:14:14 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
if (!file)
|
|
|
|
return core_info_cache_list_new();
|
|
|
|
|
|
|
|
/* Parse info cache file */
|
2022-07-22 20:23:54 +00:00
|
|
|
if (!(parser = rjson_open_stream(file)))
|
2019-04-28 03:15:21 +00:00
|
|
|
{
|
2024-04-23 16:53:50 +00:00
|
|
|
RARCH_ERR("[Core Info]: Failed to create JSON parser.\n");
|
2021-05-06 10:58:45 +00:00
|
|
|
goto end;
|
2019-04-28 03:15:21 +00:00
|
|
|
}
|
2013-06-24 01:18:23 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
rjson_set_options(parser,
|
|
|
|
RJSON_OPTION_ALLOW_UTF8BOM
|
|
|
|
| RJSON_OPTION_ALLOW_COMMENTS
|
|
|
|
| RJSON_OPTION_ALLOW_UNESCAPED_CONTROL_CHARACTERS
|
|
|
|
| RJSON_OPTION_REPLACE_INVALID_ENCODING);
|
2021-05-04 14:01:17 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
if (rjson_parse(parser, &context,
|
|
|
|
CCJSONObjectMemberHandler,
|
|
|
|
CCJSONStringHandler,
|
|
|
|
CCJSONNumberHandler,
|
|
|
|
CCJSONStartObjectHandler,
|
|
|
|
CCJSONEndObjectHandler,
|
|
|
|
CCJSONStartArrayHandler,
|
|
|
|
CCJSONEndArrayHandler,
|
|
|
|
CCJSONBoolHandler,
|
|
|
|
NULL) /* Unused null handler */
|
|
|
|
!= RJSON_DONE)
|
2013-06-24 01:18:23 +00:00
|
|
|
{
|
2024-04-23 16:53:50 +00:00
|
|
|
RARCH_WARN("[Core Info]: Error parsing chunk:\n---snip---\n%.*s\n---snip---\n",
|
2021-05-06 10:58:45 +00:00
|
|
|
rjson_get_source_context_len(parser),
|
|
|
|
rjson_get_source_context_buf(parser));
|
2024-04-23 16:53:50 +00:00
|
|
|
RARCH_WARN("[Core Info]: Error: Invalid JSON at line %d, column %d - %s.\n",
|
2021-05-06 10:58:45 +00:00
|
|
|
(int)rjson_get_source_line(parser),
|
|
|
|
(int)rjson_get_source_column(parser),
|
2024-06-16 17:42:32 +00:00
|
|
|
(*rjson_get_error(parser)
|
|
|
|
? rjson_get_error(parser)
|
2021-11-23 04:05:09 +00:00
|
|
|
: "format error"));
|
2021-04-26 13:24:24 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
/* Info cache is corrupt - discard it */
|
|
|
|
core_info_cache_list_free(context.core_info_cache_list);
|
|
|
|
core_info_cache_list = core_info_cache_list_new();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
core_info_cache_list = context.core_info_cache_list;
|
2021-04-26 13:24:24 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
rjson_free(parser);
|
2020-06-22 14:01:49 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
/* Clean up leftovers in the event of
|
|
|
|
* a parsing error */
|
|
|
|
if (context.core_info)
|
|
|
|
{
|
|
|
|
core_info_free(context.core_info);
|
|
|
|
free(context.core_info);
|
|
|
|
}
|
2021-05-04 14:01:17 +00:00
|
|
|
|
2022-03-05 13:39:56 +00:00
|
|
|
if (!core_info_cache_list)
|
|
|
|
goto end;
|
|
|
|
|
2022-02-02 15:49:53 +00:00
|
|
|
/* If info cache file has the wrong version
|
|
|
|
* number, discard it */
|
2022-12-05 11:56:55 +00:00
|
|
|
if ( string_is_empty(core_info_cache_list->version)
|
|
|
|
|| !string_is_equal(core_info_cache_list->version,
|
2022-02-02 15:49:53 +00:00
|
|
|
CORE_INFO_CACHE_VERSION))
|
|
|
|
{
|
2024-04-23 16:53:50 +00:00
|
|
|
RARCH_WARN("[Core Info]: Core info cache has invalid version"
|
|
|
|
" - forcing refresh (required v%s, found v%s).\n",
|
2022-02-02 15:49:53 +00:00
|
|
|
CORE_INFO_CACHE_VERSION,
|
|
|
|
core_info_cache_list->version);
|
|
|
|
|
|
|
|
core_info_cache_list_free(context.core_info_cache_list);
|
|
|
|
core_info_cache_list = core_info_cache_list_new();
|
|
|
|
}
|
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
end:
|
|
|
|
intfstream_close(file);
|
|
|
|
free(file);
|
2020-05-27 16:00:47 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
return core_info_cache_list;
|
|
|
|
}
|
2021-11-23 04:05:09 +00:00
|
|
|
#endif
|
2017-01-13 17:35:20 +00:00
|
|
|
|
2021-07-19 15:37:07 +00:00
|
|
|
static bool core_info_cache_write(core_info_cache_list_t *list, const char *info_dir)
|
2021-05-06 10:58:45 +00:00
|
|
|
{
|
|
|
|
intfstream_t *file = NULL;
|
|
|
|
rjsonwriter_t *writer = NULL;
|
2021-07-19 15:37:07 +00:00
|
|
|
bool success = false;
|
2021-05-06 10:58:45 +00:00
|
|
|
char file_path[PATH_MAX_LENGTH];
|
|
|
|
size_t i, j;
|
2020-06-22 14:01:49 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
if (!list)
|
2021-07-19 15:37:07 +00:00
|
|
|
return false;
|
2020-06-18 16:08:57 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
/* Open info cache file */
|
|
|
|
if (string_is_empty(info_dir))
|
|
|
|
strlcpy(file_path, FILE_PATH_CORE_INFO_CACHE, sizeof(file_path));
|
|
|
|
else
|
2022-08-04 12:18:11 +00:00
|
|
|
fill_pathname_join_special(file_path, info_dir,
|
|
|
|
FILE_PATH_CORE_INFO_CACHE,
|
2021-05-06 10:58:45 +00:00
|
|
|
sizeof(file_path));
|
2021-05-04 14:01:17 +00:00
|
|
|
|
2021-05-07 09:16:21 +00:00
|
|
|
#if defined(CORE_INFO_CACHE_COMPRESS)
|
2021-05-06 10:58:45 +00:00
|
|
|
file = intfstream_open_rzip_file(file_path,
|
|
|
|
RETRO_VFS_FILE_ACCESS_WRITE);
|
|
|
|
#else
|
|
|
|
file = intfstream_open_file(file_path,
|
|
|
|
RETRO_VFS_FILE_ACCESS_WRITE,
|
|
|
|
RETRO_VFS_FILE_ACCESS_HINT_NONE);
|
2021-05-04 14:01:17 +00:00
|
|
|
#endif
|
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
if (!file)
|
|
|
|
{
|
2024-04-23 16:53:50 +00:00
|
|
|
RARCH_ERR("[Core Info]: Failed to write core info cache file: \"%s\".\n", file_path);
|
2021-07-19 15:37:07 +00:00
|
|
|
return false;
|
2013-06-24 01:18:23 +00:00
|
|
|
}
|
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
/* Write info cache */
|
2022-07-22 20:23:54 +00:00
|
|
|
if (!(writer = rjsonwriter_open_stream(file)))
|
2020-06-26 16:40:26 +00:00
|
|
|
{
|
2024-04-23 16:53:50 +00:00
|
|
|
RARCH_ERR("[Core Info]: Failed to create JSON writer.\n");
|
2021-05-06 10:58:45 +00:00
|
|
|
goto end;
|
2020-06-26 16:40:26 +00:00
|
|
|
}
|
|
|
|
|
2021-05-07 09:16:21 +00:00
|
|
|
#if defined(CORE_INFO_CACHE_COMPRESS)
|
|
|
|
/* When compressing info cache, human readability
|
|
|
|
* is not a factor - can skip all indentation
|
|
|
|
* and new line characters */
|
|
|
|
rjsonwriter_set_options(writer, RJSONWRITER_OPTION_SKIP_WHITESPACE);
|
|
|
|
#endif
|
|
|
|
|
2022-08-26 12:44:29 +00:00
|
|
|
rjsonwriter_raw(writer, "{", 1);
|
|
|
|
rjsonwriter_raw(writer, "\n", 1);
|
2021-05-06 10:58:45 +00:00
|
|
|
rjsonwriter_add_spaces(writer, 2);
|
|
|
|
rjsonwriter_add_string(writer, "version");
|
2022-08-26 12:44:29 +00:00
|
|
|
rjsonwriter_raw(writer, ":", 1);
|
|
|
|
rjsonwriter_raw(writer, " ", 1);
|
2022-02-02 15:49:53 +00:00
|
|
|
rjsonwriter_add_string(writer, CORE_INFO_CACHE_VERSION);
|
2022-08-26 12:44:29 +00:00
|
|
|
rjsonwriter_raw(writer, ",", 1);
|
|
|
|
rjsonwriter_raw(writer, "\n", 1);
|
2021-05-06 10:58:45 +00:00
|
|
|
rjsonwriter_add_spaces(writer, 2);
|
|
|
|
rjsonwriter_add_string(writer, "items");
|
2022-08-26 12:44:29 +00:00
|
|
|
rjsonwriter_raw(writer, ":", 1);
|
|
|
|
rjsonwriter_raw(writer, " ", 1);
|
|
|
|
rjsonwriter_raw(writer, "[", 1);
|
|
|
|
rjsonwriter_raw(writer, "\n", 1);
|
2020-06-26 16:40:26 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
for (i = 0; i < list->length; i++)
|
|
|
|
{
|
|
|
|
core_info_t* info = &list->items[i];
|
2013-10-05 16:33:22 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
if (!info || !info->is_installed)
|
|
|
|
continue;
|
2013-10-05 16:33:22 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
if (i > 0)
|
2022-08-26 12:44:29 +00:00
|
|
|
{
|
|
|
|
rjsonwriter_raw(writer, ",", 1);
|
|
|
|
rjsonwriter_raw(writer, "\n", 1);
|
|
|
|
}
|
2016-12-14 12:47:22 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
rjsonwriter_add_spaces(writer, 4);
|
2022-08-26 12:44:29 +00:00
|
|
|
rjsonwriter_raw(writer, "{", 1);
|
|
|
|
rjsonwriter_raw(writer, "\n", 1);
|
2013-06-26 00:57:19 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
rjsonwriter_add_spaces(writer, 6);
|
|
|
|
rjsonwriter_add_string(writer, "display_name");
|
2022-08-26 12:44:29 +00:00
|
|
|
rjsonwriter_raw(writer, ":", 1);
|
|
|
|
rjsonwriter_raw(writer, " ", 1);
|
2021-05-06 10:58:45 +00:00
|
|
|
rjsonwriter_add_string(writer, info->display_name);
|
2022-08-26 12:44:29 +00:00
|
|
|
rjsonwriter_raw(writer, ",", 1);
|
|
|
|
rjsonwriter_raw(writer, "\n", 1);
|
2014-12-12 19:25:57 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
rjsonwriter_add_spaces(writer, 6);
|
|
|
|
rjsonwriter_add_string(writer, "display_version");
|
2022-08-26 12:44:29 +00:00
|
|
|
rjsonwriter_raw(writer, ":", 1);
|
|
|
|
rjsonwriter_raw(writer, " ", 1);
|
2021-05-06 10:58:45 +00:00
|
|
|
rjsonwriter_add_string(writer, info->display_version);
|
2022-08-26 12:44:29 +00:00
|
|
|
rjsonwriter_raw(writer, ",", 1);
|
|
|
|
rjsonwriter_raw(writer, "\n", 1);
|
2013-10-05 15:07:56 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
rjsonwriter_add_spaces(writer, 6);
|
|
|
|
rjsonwriter_add_string(writer, "core_name");
|
2022-08-26 12:44:29 +00:00
|
|
|
rjsonwriter_raw(writer, ":", 1);
|
|
|
|
rjsonwriter_raw(writer, " ", 1);
|
2021-05-06 10:58:45 +00:00
|
|
|
rjsonwriter_add_string(writer, info->core_name);
|
2022-08-26 12:44:29 +00:00
|
|
|
rjsonwriter_raw(writer, ",", 1);
|
|
|
|
rjsonwriter_raw(writer, "\n", 1);
|
2014-08-02 12:01:35 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
rjsonwriter_add_spaces(writer, 6);
|
|
|
|
rjsonwriter_add_string(writer, "system_manufacturer");
|
2022-08-26 12:44:29 +00:00
|
|
|
rjsonwriter_raw(writer, ":", 1);
|
|
|
|
rjsonwriter_raw(writer, " ", 1);
|
2021-05-06 10:58:45 +00:00
|
|
|
rjsonwriter_add_string(writer, info->system_manufacturer);
|
2022-08-26 12:44:29 +00:00
|
|
|
rjsonwriter_raw(writer, ",", 1);
|
|
|
|
rjsonwriter_raw(writer, "\n", 1);
|
2014-03-03 06:02:29 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
rjsonwriter_add_spaces(writer, 6);
|
|
|
|
rjsonwriter_add_string(writer, "systemname");
|
2022-08-26 12:44:29 +00:00
|
|
|
rjsonwriter_raw(writer, ":", 1);
|
|
|
|
rjsonwriter_raw(writer, " ", 1);
|
2021-05-06 10:58:45 +00:00
|
|
|
rjsonwriter_add_string(writer, info->systemname);
|
2022-08-26 12:44:29 +00:00
|
|
|
rjsonwriter_raw(writer, ",", 1);
|
|
|
|
rjsonwriter_raw(writer, "\n", 1);
|
2016-02-07 18:02:09 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
rjsonwriter_add_spaces(writer, 6);
|
|
|
|
rjsonwriter_add_string(writer, "system_id");
|
2022-08-26 12:44:29 +00:00
|
|
|
rjsonwriter_raw(writer, ":", 1);
|
|
|
|
rjsonwriter_raw(writer, " ", 1);
|
2021-05-06 10:58:45 +00:00
|
|
|
rjsonwriter_add_string(writer, info->system_id);
|
2022-08-26 12:44:29 +00:00
|
|
|
rjsonwriter_raw(writer, ",", 1);
|
|
|
|
rjsonwriter_raw(writer, "\n", 1);
|
2016-12-14 10:47:04 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
rjsonwriter_add_spaces(writer, 6);
|
|
|
|
rjsonwriter_add_string(writer, "supported_extensions");
|
2022-08-26 12:44:29 +00:00
|
|
|
rjsonwriter_raw(writer, ":", 1);
|
|
|
|
rjsonwriter_raw(writer, " ", 1);
|
2021-05-06 10:58:45 +00:00
|
|
|
rjsonwriter_add_string(writer, info->supported_extensions);
|
2022-08-26 12:44:29 +00:00
|
|
|
rjsonwriter_raw(writer, ",", 1);
|
|
|
|
rjsonwriter_raw(writer, "\n", 1);
|
2018-02-04 22:07:24 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
rjsonwriter_add_spaces(writer, 6);
|
|
|
|
rjsonwriter_add_string(writer, "authors");
|
2022-08-26 12:44:29 +00:00
|
|
|
rjsonwriter_raw(writer, ":", 1);
|
|
|
|
rjsonwriter_raw(writer, " ", 1);
|
2021-05-06 10:58:45 +00:00
|
|
|
rjsonwriter_add_string(writer, info->authors);
|
2022-08-26 12:44:29 +00:00
|
|
|
rjsonwriter_raw(writer, ",", 1);
|
|
|
|
rjsonwriter_raw(writer, "\n", 1);
|
2021-05-06 10:58:45 +00:00
|
|
|
|
|
|
|
rjsonwriter_add_spaces(writer, 6);
|
|
|
|
rjsonwriter_add_string(writer, "permissions");
|
2022-08-26 12:44:29 +00:00
|
|
|
rjsonwriter_raw(writer, ":", 1);
|
|
|
|
rjsonwriter_raw(writer, " ", 1);
|
2021-05-06 10:58:45 +00:00
|
|
|
rjsonwriter_add_string(writer, info->permissions);
|
2022-08-26 12:44:29 +00:00
|
|
|
rjsonwriter_raw(writer, ",", 1);
|
|
|
|
rjsonwriter_raw(writer, "\n", 1);
|
2021-05-06 10:58:45 +00:00
|
|
|
|
|
|
|
rjsonwriter_add_spaces(writer, 6);
|
|
|
|
rjsonwriter_add_string(writer, "licenses");
|
2022-08-26 12:44:29 +00:00
|
|
|
rjsonwriter_raw(writer, ":", 1);
|
|
|
|
rjsonwriter_raw(writer, " ", 1);
|
2021-05-06 10:58:45 +00:00
|
|
|
rjsonwriter_add_string(writer, info->licenses);
|
2022-08-26 12:44:29 +00:00
|
|
|
rjsonwriter_raw(writer, ",", 1);
|
|
|
|
rjsonwriter_raw(writer, "\n", 1);
|
2021-05-06 10:58:45 +00:00
|
|
|
|
|
|
|
rjsonwriter_add_spaces(writer, 6);
|
|
|
|
rjsonwriter_add_string(writer, "categories");
|
2022-08-26 12:44:29 +00:00
|
|
|
rjsonwriter_raw(writer, ":", 1);
|
|
|
|
rjsonwriter_raw(writer, " ", 1);
|
2021-05-06 10:58:45 +00:00
|
|
|
rjsonwriter_add_string(writer, info->categories);
|
2022-08-26 12:44:29 +00:00
|
|
|
rjsonwriter_raw(writer, ",", 1);
|
|
|
|
rjsonwriter_raw(writer, "\n", 1);
|
2021-05-06 10:58:45 +00:00
|
|
|
|
|
|
|
rjsonwriter_add_spaces(writer, 6);
|
|
|
|
rjsonwriter_add_string(writer, "databases");
|
2022-08-26 12:44:29 +00:00
|
|
|
rjsonwriter_raw(writer, ":", 1);
|
|
|
|
rjsonwriter_raw(writer, " ", 1);
|
2021-05-06 10:58:45 +00:00
|
|
|
rjsonwriter_add_string(writer, info->databases);
|
2022-08-26 12:44:29 +00:00
|
|
|
rjsonwriter_raw(writer, ",", 1);
|
|
|
|
rjsonwriter_raw(writer, "\n", 1);
|
2021-05-06 10:58:45 +00:00
|
|
|
|
|
|
|
rjsonwriter_add_spaces(writer, 6);
|
|
|
|
rjsonwriter_add_string(writer, "notes");
|
2022-08-26 12:44:29 +00:00
|
|
|
rjsonwriter_raw(writer, ":", 1);
|
|
|
|
rjsonwriter_raw(writer, " ", 1);
|
2021-05-06 10:58:45 +00:00
|
|
|
rjsonwriter_add_string(writer, info->notes);
|
2022-08-26 12:44:29 +00:00
|
|
|
rjsonwriter_raw(writer, ",", 1);
|
|
|
|
rjsonwriter_raw(writer, "\n", 1);
|
2021-05-06 10:58:45 +00:00
|
|
|
|
|
|
|
rjsonwriter_add_spaces(writer, 6);
|
|
|
|
rjsonwriter_add_string(writer, "required_hw_api");
|
2022-08-26 12:44:29 +00:00
|
|
|
rjsonwriter_raw(writer, ":", 1);
|
|
|
|
rjsonwriter_raw(writer, " ", 1);
|
2021-05-06 10:58:45 +00:00
|
|
|
rjsonwriter_add_string(writer, info->required_hw_api);
|
2022-08-26 12:44:29 +00:00
|
|
|
rjsonwriter_raw(writer, ",", 1);
|
|
|
|
rjsonwriter_raw(writer, "\n", 1);
|
2021-05-06 10:58:45 +00:00
|
|
|
|
|
|
|
rjsonwriter_add_spaces(writer, 6);
|
|
|
|
rjsonwriter_add_string(writer, "description");
|
2022-08-26 12:44:29 +00:00
|
|
|
rjsonwriter_raw(writer, ":", 1);
|
|
|
|
rjsonwriter_raw(writer, " ", 1);
|
2021-05-06 10:58:45 +00:00
|
|
|
rjsonwriter_add_string(writer, info->description);
|
2022-08-26 12:44:29 +00:00
|
|
|
rjsonwriter_raw(writer, ",", 1);
|
|
|
|
rjsonwriter_raw(writer, "\n", 1);
|
2021-05-06 10:58:45 +00:00
|
|
|
|
|
|
|
if (info->firmware_count > 0)
|
|
|
|
{
|
|
|
|
rjsonwriter_add_spaces(writer, 6);
|
|
|
|
rjsonwriter_add_string(writer, "firmware");
|
2022-08-26 12:44:29 +00:00
|
|
|
rjsonwriter_raw(writer, ":", 1);
|
|
|
|
rjsonwriter_raw(writer, " ", 1);
|
|
|
|
rjsonwriter_raw(writer, "[", 1);
|
|
|
|
rjsonwriter_raw(writer, "\n", 1);
|
2021-05-06 10:58:45 +00:00
|
|
|
|
|
|
|
for (j = 0; j < info->firmware_count; j++)
|
|
|
|
{
|
|
|
|
rjsonwriter_add_spaces(writer, 8);
|
2022-08-26 12:44:29 +00:00
|
|
|
rjsonwriter_raw(writer, "{", 1);
|
|
|
|
rjsonwriter_raw(writer, "\n", 1);
|
2021-05-06 10:58:45 +00:00
|
|
|
rjsonwriter_add_spaces(writer, 10);
|
|
|
|
rjsonwriter_add_string(writer, "path");
|
2022-08-26 12:44:29 +00:00
|
|
|
rjsonwriter_raw(writer, ":", 1);
|
|
|
|
rjsonwriter_raw(writer, " ", 1);
|
2021-05-06 10:58:45 +00:00
|
|
|
rjsonwriter_add_string(writer, info->firmware[j].path);
|
2022-08-26 12:44:29 +00:00
|
|
|
rjsonwriter_raw(writer, ",", 1);
|
|
|
|
rjsonwriter_raw(writer, "\n", 1);
|
2021-05-06 10:58:45 +00:00
|
|
|
rjsonwriter_add_spaces(writer, 10);
|
|
|
|
rjsonwriter_add_string(writer, "desc");
|
2022-08-26 12:44:29 +00:00
|
|
|
rjsonwriter_raw(writer, ":", 1);
|
|
|
|
rjsonwriter_raw(writer, " ", 1);
|
2021-05-06 10:58:45 +00:00
|
|
|
rjsonwriter_add_string(writer, info->firmware[j].desc);
|
2022-08-26 12:44:29 +00:00
|
|
|
rjsonwriter_raw(writer, ",", 1);
|
|
|
|
rjsonwriter_raw(writer, "\n", 1);
|
2021-05-06 10:58:45 +00:00
|
|
|
rjsonwriter_add_spaces(writer, 10);
|
|
|
|
rjsonwriter_add_string(writer, "optional");
|
2022-08-26 12:44:29 +00:00
|
|
|
rjsonwriter_raw(writer, ":", 1);
|
|
|
|
rjsonwriter_raw(writer, " ", 1);
|
2022-08-01 15:41:34 +00:00
|
|
|
{
|
|
|
|
bool value = info->firmware[j].optional;
|
|
|
|
rjsonwriter_raw(writer, (value ? "true" : "false"), (value ? 4 : 5));
|
|
|
|
}
|
|
|
|
rjsonwriter_raw(writer, "\n", 1);
|
2021-05-06 10:58:45 +00:00
|
|
|
rjsonwriter_add_spaces(writer, 8);
|
2022-08-01 15:41:34 +00:00
|
|
|
rjsonwriter_raw(writer, "}", 1);
|
2021-05-06 10:58:45 +00:00
|
|
|
|
|
|
|
if (j < info->firmware_count - 1)
|
2022-08-01 15:41:34 +00:00
|
|
|
rjsonwriter_raw(writer, ",", 1);
|
2021-05-06 10:58:45 +00:00
|
|
|
|
2022-08-01 15:41:34 +00:00
|
|
|
rjsonwriter_raw(writer, "\n", 1);
|
2021-05-06 10:58:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
rjsonwriter_add_spaces(writer, 6);
|
2022-08-26 12:44:29 +00:00
|
|
|
rjsonwriter_raw(writer, "]", 1);
|
|
|
|
rjsonwriter_raw(writer, ",", 1);
|
|
|
|
rjsonwriter_raw(writer, "\n", 1);
|
2021-05-06 10:58:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
rjsonwriter_add_spaces(writer, 6);
|
|
|
|
rjsonwriter_add_string(writer, "core_file_id");
|
2022-08-26 12:44:29 +00:00
|
|
|
rjsonwriter_raw(writer, ":", 1);
|
|
|
|
rjsonwriter_raw(writer, "\n", 1);
|
2021-05-06 10:58:45 +00:00
|
|
|
rjsonwriter_add_spaces(writer, 6);
|
2022-08-26 12:44:29 +00:00
|
|
|
rjsonwriter_raw(writer, "{", 1);
|
|
|
|
rjsonwriter_raw(writer, "\n", 1);
|
2021-05-06 10:58:45 +00:00
|
|
|
rjsonwriter_add_spaces(writer, 8);
|
|
|
|
rjsonwriter_add_string(writer, "str");
|
2022-08-26 12:44:29 +00:00
|
|
|
rjsonwriter_raw(writer, ":", 1);
|
|
|
|
rjsonwriter_raw(writer, " ", 1);
|
2021-05-06 10:58:45 +00:00
|
|
|
rjsonwriter_add_string(writer, info->core_file_id.str);
|
2022-08-26 12:44:29 +00:00
|
|
|
rjsonwriter_raw(writer, ",", 1);
|
|
|
|
rjsonwriter_raw(writer, "\n", 1);
|
2021-05-06 10:58:45 +00:00
|
|
|
rjsonwriter_add_spaces(writer, 8);
|
|
|
|
rjsonwriter_add_string(writer, "hash");
|
2022-08-26 12:44:29 +00:00
|
|
|
rjsonwriter_raw(writer, ":", 1);
|
|
|
|
rjsonwriter_raw(writer, " ", 1);
|
2022-08-01 15:41:34 +00:00
|
|
|
rjsonwriter_rawf(writer, "%u", info->core_file_id.hash);
|
|
|
|
rjsonwriter_raw(writer, "\n", 1);
|
2021-05-06 10:58:45 +00:00
|
|
|
rjsonwriter_add_spaces(writer, 6);
|
2022-08-26 12:44:29 +00:00
|
|
|
rjsonwriter_raw(writer, "}", 1);
|
|
|
|
rjsonwriter_raw(writer, ",", 1);
|
|
|
|
rjsonwriter_raw(writer, "\n", 1);
|
2021-05-06 10:58:45 +00:00
|
|
|
|
|
|
|
rjsonwriter_add_spaces(writer, 6);
|
|
|
|
rjsonwriter_add_string(writer, "firmware_count");
|
2022-08-26 12:44:29 +00:00
|
|
|
rjsonwriter_raw(writer, ":", 1);
|
|
|
|
rjsonwriter_raw(writer, " ", 1);
|
2022-08-01 15:41:34 +00:00
|
|
|
rjsonwriter_rawf(writer, "%u", info->firmware_count);
|
2022-08-26 12:44:29 +00:00
|
|
|
rjsonwriter_raw(writer, ",", 1);
|
|
|
|
rjsonwriter_raw(writer, "\n", 1);
|
2021-05-06 10:58:45 +00:00
|
|
|
|
2022-02-02 15:49:53 +00:00
|
|
|
rjsonwriter_add_spaces(writer, 6);
|
|
|
|
rjsonwriter_add_string(writer, "savestate_support_level");
|
2022-08-26 12:44:29 +00:00
|
|
|
rjsonwriter_raw(writer, ":", 1);
|
|
|
|
rjsonwriter_raw(writer, " ", 1);
|
2022-08-01 15:41:34 +00:00
|
|
|
rjsonwriter_rawf(writer, "%u", info->savestate_support_level);
|
2022-08-26 12:44:29 +00:00
|
|
|
rjsonwriter_raw(writer, ",", 1);
|
|
|
|
rjsonwriter_raw(writer, "\n", 1);
|
2022-02-02 15:49:53 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
rjsonwriter_add_spaces(writer, 6);
|
|
|
|
rjsonwriter_add_string(writer, "has_info");
|
2022-08-26 12:44:29 +00:00
|
|
|
rjsonwriter_raw(writer, ":", 1);
|
|
|
|
rjsonwriter_raw(writer, " ", 1);
|
2022-08-01 15:41:34 +00:00
|
|
|
{
|
|
|
|
bool value = info->has_info;
|
|
|
|
rjsonwriter_raw(writer, (value ? "true" : "false"), (value ? 4 : 5));
|
|
|
|
}
|
2022-08-26 12:44:29 +00:00
|
|
|
rjsonwriter_raw(writer, ",", 1);
|
|
|
|
rjsonwriter_raw(writer, "\n", 1);
|
2021-05-06 10:58:45 +00:00
|
|
|
|
|
|
|
rjsonwriter_add_spaces(writer, 6);
|
|
|
|
rjsonwriter_add_string(writer, "supports_no_game");
|
2022-08-26 12:44:29 +00:00
|
|
|
rjsonwriter_raw(writer, ":", 1);
|
|
|
|
rjsonwriter_raw(writer, " ", 1);
|
2022-08-01 15:41:34 +00:00
|
|
|
{
|
|
|
|
bool value = info->supports_no_game;
|
|
|
|
rjsonwriter_raw(writer, (value ? "true" : "false"), (value ? 4 : 5));
|
|
|
|
}
|
2022-08-26 12:44:29 +00:00
|
|
|
rjsonwriter_raw(writer, ",", 1);
|
|
|
|
rjsonwriter_raw(writer, "\n", 1);
|
2021-05-06 10:58:45 +00:00
|
|
|
|
2022-02-22 18:23:48 +00:00
|
|
|
rjsonwriter_add_spaces(writer, 6);
|
|
|
|
rjsonwriter_add_string(writer, "single_purpose");
|
2022-08-26 12:44:29 +00:00
|
|
|
rjsonwriter_raw(writer, ":", 1);
|
|
|
|
rjsonwriter_raw(writer, " ", 1);
|
2022-08-01 15:41:34 +00:00
|
|
|
{
|
|
|
|
bool value = info->single_purpose;
|
|
|
|
rjsonwriter_raw(writer, (value ? "true" : "false"), (value ? 4 : 5));
|
|
|
|
}
|
2022-08-26 12:44:29 +00:00
|
|
|
rjsonwriter_raw(writer, ",", 1);
|
|
|
|
rjsonwriter_raw(writer, "\n", 1);
|
2022-02-22 18:23:48 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
rjsonwriter_add_spaces(writer, 6);
|
|
|
|
rjsonwriter_add_string(writer, "database_match_archive_member");
|
2022-08-26 12:44:29 +00:00
|
|
|
rjsonwriter_raw(writer, ":", 1);
|
|
|
|
rjsonwriter_raw(writer, " ", 1);
|
2022-08-01 15:41:34 +00:00
|
|
|
{
|
|
|
|
bool value = info->database_match_archive_member;
|
|
|
|
rjsonwriter_raw(writer, (value ? "true" : "false"), (value ? 4 : 5));
|
|
|
|
}
|
2022-08-26 12:44:29 +00:00
|
|
|
rjsonwriter_raw(writer, ",", 1);
|
|
|
|
rjsonwriter_raw(writer, "\n", 1);
|
2021-05-06 10:58:45 +00:00
|
|
|
|
|
|
|
rjsonwriter_add_spaces(writer, 6);
|
|
|
|
rjsonwriter_add_string(writer, "is_experimental");
|
2022-08-26 12:44:29 +00:00
|
|
|
rjsonwriter_raw(writer, ":", 1);
|
|
|
|
rjsonwriter_raw(writer, " ", 1);
|
2022-08-01 15:41:34 +00:00
|
|
|
{
|
|
|
|
bool value = info->is_experimental;
|
|
|
|
rjsonwriter_raw(writer, (value ? "true" : "false"), (value ? 4 : 5));
|
|
|
|
}
|
|
|
|
rjsonwriter_raw(writer, "\n", 1);
|
2021-05-06 10:58:45 +00:00
|
|
|
|
|
|
|
rjsonwriter_add_spaces(writer, 4);
|
2022-08-01 15:41:34 +00:00
|
|
|
rjsonwriter_raw(writer, "}", 1);
|
2021-05-06 10:58:45 +00:00
|
|
|
}
|
|
|
|
|
2022-08-01 15:41:34 +00:00
|
|
|
rjsonwriter_raw(writer, "\n", 1);
|
2021-05-06 10:58:45 +00:00
|
|
|
rjsonwriter_add_spaces(writer, 2);
|
2022-08-26 12:44:29 +00:00
|
|
|
rjsonwriter_raw(writer, "]", 1);
|
|
|
|
rjsonwriter_raw(writer, "\n", 1);
|
|
|
|
rjsonwriter_raw(writer, "}", 1);
|
|
|
|
rjsonwriter_raw(writer, "\n", 1);
|
2021-05-06 10:58:45 +00:00
|
|
|
rjsonwriter_free(writer);
|
|
|
|
|
2024-04-23 16:53:50 +00:00
|
|
|
RARCH_LOG("[Core Info]: Wrote to cache file: \"%s\".\n", file_path);
|
2021-07-19 15:37:07 +00:00
|
|
|
success = true;
|
2021-05-06 10:58:45 +00:00
|
|
|
|
|
|
|
/* Remove 'force refresh' file, if required */
|
|
|
|
if (string_is_empty(info_dir))
|
2021-11-23 04:05:09 +00:00
|
|
|
strlcpy(file_path,
|
|
|
|
FILE_PATH_CORE_INFO_CACHE_REFRESH, sizeof(file_path));
|
2021-05-06 10:58:45 +00:00
|
|
|
else
|
2022-08-04 12:18:11 +00:00
|
|
|
fill_pathname_join_special(file_path,
|
2021-11-23 04:05:09 +00:00
|
|
|
info_dir, FILE_PATH_CORE_INFO_CACHE_REFRESH,
|
2021-05-06 10:58:45 +00:00
|
|
|
sizeof(file_path));
|
|
|
|
|
|
|
|
if (path_is_valid(file_path))
|
|
|
|
filestream_delete(file_path);
|
|
|
|
|
|
|
|
end:
|
|
|
|
intfstream_close(file);
|
|
|
|
free(file);
|
|
|
|
|
|
|
|
list->refresh = false;
|
2021-07-19 15:37:07 +00:00
|
|
|
return success;
|
2021-05-06 10:58:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void core_info_check_uninstalled(core_info_cache_list_t *list)
|
|
|
|
{
|
|
|
|
size_t i;
|
|
|
|
|
|
|
|
if (!list)
|
|
|
|
return;
|
|
|
|
|
|
|
|
for (i = 0; i < list->length; i++)
|
2014-03-03 06:02:29 +00:00
|
|
|
{
|
2021-05-06 10:58:45 +00:00
|
|
|
core_info_t *info = (core_info_t *)&list->items[i];
|
|
|
|
|
|
|
|
if (!info)
|
2015-01-11 06:37:02 +00:00
|
|
|
continue;
|
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
if (!info->is_installed)
|
|
|
|
{
|
|
|
|
list->refresh = true;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* When called, generates a temporary file
|
|
|
|
* that will force an info cache refresh the
|
|
|
|
* next time that core info is initialised with
|
|
|
|
* caching enabled */
|
|
|
|
bool core_info_cache_force_refresh(const char *path_info)
|
|
|
|
{
|
|
|
|
char file_path[PATH_MAX_LENGTH];
|
|
|
|
|
|
|
|
/* Get 'force refresh' file path */
|
|
|
|
if (string_is_empty(path_info))
|
2021-11-23 04:05:09 +00:00
|
|
|
strlcpy(file_path,
|
|
|
|
FILE_PATH_CORE_INFO_CACHE_REFRESH, sizeof(file_path));
|
2021-05-06 10:58:45 +00:00
|
|
|
else
|
2022-08-04 12:18:11 +00:00
|
|
|
fill_pathname_join_special(file_path,
|
2021-11-23 04:05:09 +00:00
|
|
|
path_info, FILE_PATH_CORE_INFO_CACHE_REFRESH,
|
2021-05-06 10:58:45 +00:00
|
|
|
sizeof(file_path));
|
|
|
|
|
|
|
|
/* Generate a new, empty 'force refresh' file,
|
|
|
|
* if required */
|
|
|
|
if (!path_is_valid(file_path))
|
|
|
|
{
|
|
|
|
RFILE *refresh_file = filestream_open(
|
|
|
|
file_path,
|
|
|
|
RETRO_VFS_FILE_ACCESS_WRITE,
|
|
|
|
RETRO_VFS_FILE_ACCESS_HINT_NONE);
|
|
|
|
|
|
|
|
if (!refresh_file)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
/* We have to write something - just output
|
|
|
|
* a single character */
|
|
|
|
if (filestream_putc(refresh_file, 0) != 0)
|
|
|
|
{
|
|
|
|
filestream_close(refresh_file);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
filestream_close(refresh_file);
|
2014-03-03 06:02:29 +00:00
|
|
|
}
|
2016-02-07 15:19:02 +00:00
|
|
|
|
|
|
|
return true;
|
2014-03-03 06:02:29 +00:00
|
|
|
}
|
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
/***********************/
|
|
|
|
/* Core Info Cache END */
|
|
|
|
/***********************/
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
const char *path;
|
|
|
|
const char *filename;
|
|
|
|
} core_file_path_t;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
core_file_path_t *list;
|
|
|
|
size_t size;
|
|
|
|
} core_file_path_list_t;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
const char *filename;
|
|
|
|
uint32_t hash;
|
2022-03-09 16:49:16 +00:00
|
|
|
} core_aux_file_path_t;
|
2021-05-06 10:58:45 +00:00
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
2022-03-09 16:49:16 +00:00
|
|
|
core_aux_file_path_t *list;
|
2021-05-06 10:58:45 +00:00
|
|
|
size_t size;
|
2022-03-09 16:49:16 +00:00
|
|
|
} core_aux_file_path_list_t;
|
2021-05-06 10:58:45 +00:00
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
struct string_list *dir_list;
|
|
|
|
core_file_path_list_t *core_list;
|
2022-03-09 16:49:16 +00:00
|
|
|
core_aux_file_path_list_t *lock_list;
|
|
|
|
core_aux_file_path_list_t *standalone_exempt_list;
|
2021-05-06 10:58:45 +00:00
|
|
|
} core_path_list_t;
|
|
|
|
|
|
|
|
static uint32_t core_info_hash_string(const char *str)
|
|
|
|
{
|
|
|
|
unsigned char c;
|
|
|
|
uint32_t hash = (uint32_t)0x811c9dc5;
|
|
|
|
while ((c = (unsigned char)*(str++)) != '\0')
|
|
|
|
hash = ((hash * (uint32_t)0x01000193) ^ (uint32_t)c);
|
|
|
|
return (hash ? hash : 1);
|
2016-05-09 16:11:17 +00:00
|
|
|
}
|
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
static void core_info_path_list_free(core_path_list_t *path_list)
|
2016-02-07 01:18:26 +00:00
|
|
|
{
|
2021-05-06 10:58:45 +00:00
|
|
|
if (!path_list)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (path_list->core_list)
|
|
|
|
{
|
|
|
|
if (path_list->core_list->list)
|
|
|
|
free(path_list->core_list->list);
|
|
|
|
free(path_list->core_list);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (path_list->lock_list)
|
|
|
|
{
|
|
|
|
if (path_list->lock_list->list)
|
|
|
|
free(path_list->lock_list->list);
|
|
|
|
free(path_list->lock_list);
|
|
|
|
}
|
|
|
|
|
2022-03-09 16:49:16 +00:00
|
|
|
if (path_list->standalone_exempt_list)
|
|
|
|
{
|
|
|
|
if (path_list->standalone_exempt_list->list)
|
|
|
|
free(path_list->standalone_exempt_list->list);
|
|
|
|
free(path_list->standalone_exempt_list);
|
|
|
|
}
|
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
if (path_list->dir_list)
|
|
|
|
string_list_free(path_list->dir_list);
|
|
|
|
|
|
|
|
free(path_list);
|
|
|
|
}
|
|
|
|
|
|
|
|
static core_path_list_t *core_info_path_list_new(const char *core_dir,
|
2021-05-07 09:58:09 +00:00
|
|
|
const char *core_exts, bool show_hidden_files)
|
2021-05-06 10:58:45 +00:00
|
|
|
{
|
2023-06-18 10:06:12 +00:00
|
|
|
size_t i, _len;
|
2022-12-05 11:56:55 +00:00
|
|
|
char exts[32];
|
|
|
|
core_path_list_t *path_list = NULL;
|
2021-05-07 09:58:09 +00:00
|
|
|
struct string_list *core_ext_list = NULL;
|
|
|
|
bool dir_list_ok = false;
|
2021-05-06 10:58:45 +00:00
|
|
|
|
2022-12-05 11:56:55 +00:00
|
|
|
if (string_is_empty(core_exts))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
if (!(path_list = (core_path_list_t*)calloc(1, sizeof(*path_list))))
|
|
|
|
return NULL;
|
2021-05-06 10:58:45 +00:00
|
|
|
|
2022-07-22 20:23:54 +00:00
|
|
|
if (!(core_ext_list = string_split(core_exts, "|")))
|
2022-12-05 11:56:55 +00:00
|
|
|
{
|
|
|
|
core_info_path_list_free(path_list);
|
|
|
|
return NULL;
|
|
|
|
}
|
2021-05-07 09:58:09 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
/* Allocate list containers */
|
2022-03-09 16:49:16 +00:00
|
|
|
path_list->dir_list = string_list_new();
|
|
|
|
path_list->core_list = (core_file_path_list_t*)
|
|
|
|
calloc(1, sizeof(*path_list->core_list));
|
|
|
|
path_list->lock_list = (core_aux_file_path_list_t*)
|
|
|
|
calloc(1, sizeof(*path_list->lock_list));
|
|
|
|
path_list->standalone_exempt_list = (core_aux_file_path_list_t*)
|
|
|
|
calloc(1, sizeof(*path_list->standalone_exempt_list));
|
2021-05-06 10:58:45 +00:00
|
|
|
|
2021-11-23 04:05:09 +00:00
|
|
|
if ( !path_list->dir_list
|
2024-06-16 17:42:32 +00:00
|
|
|
|| !path_list->core_list
|
2022-03-09 16:49:16 +00:00
|
|
|
|| !path_list->lock_list
|
|
|
|
|| !path_list->standalone_exempt_list)
|
2021-05-06 10:58:45 +00:00
|
|
|
goto error;
|
|
|
|
|
|
|
|
/* Get list of file extensions to include
|
2022-03-09 16:49:16 +00:00
|
|
|
* > core + lock */
|
2023-06-18 10:06:12 +00:00
|
|
|
_len = strlcpy(exts, core_exts, sizeof(exts));
|
2022-08-13 00:54:57 +00:00
|
|
|
#if defined(HAVE_DYNAMIC)
|
|
|
|
/* > 'standalone exempt' */
|
2023-06-18 10:06:12 +00:00
|
|
|
strlcpy(exts + _len, "|lck|lsae", sizeof(exts) - _len);
|
|
|
|
#else
|
|
|
|
strlcpy(exts + _len, "|lck", sizeof(exts) - _len);
|
2022-08-13 00:54:57 +00:00
|
|
|
#endif
|
2021-05-06 10:58:45 +00:00
|
|
|
|
|
|
|
/* Fetch core directory listing */
|
|
|
|
dir_list_ok = dir_list_append(path_list->dir_list,
|
|
|
|
core_dir, exts, false, show_hidden_files,
|
|
|
|
false, false);
|
|
|
|
|
|
|
|
#if defined(__WINRT__) || defined(WINAPI_FAMILY) && WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
|
|
|
|
{
|
|
|
|
/* UWP: browse the optional packages for additional cores */
|
|
|
|
struct string_list core_packages = {0};
|
|
|
|
|
|
|
|
if (string_list_initialize(&core_packages))
|
|
|
|
{
|
|
|
|
uwp_fill_installed_core_packages(&core_packages);
|
|
|
|
for (i = 0; i < core_packages.size; i++)
|
|
|
|
dir_list_append(path_list->dir_list,
|
|
|
|
core_packages.elems[i].data, exts, false,
|
|
|
|
show_hidden_files, false, false);
|
|
|
|
string_list_deinitialize(&core_packages);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
/* Keep the old 'directory not found' behaviour */
|
|
|
|
if (!dir_list_ok)
|
|
|
|
goto error;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Allocate sub lists */
|
2022-03-09 16:49:16 +00:00
|
|
|
path_list->core_list->list = (core_file_path_t*)
|
2021-05-06 10:58:45 +00:00
|
|
|
malloc(path_list->dir_list->size *
|
|
|
|
sizeof(*path_list->core_list->list));
|
2022-03-09 16:49:16 +00:00
|
|
|
path_list->lock_list->list = (core_aux_file_path_t*)
|
2021-05-06 10:58:45 +00:00
|
|
|
malloc(path_list->dir_list->size *
|
|
|
|
sizeof(*path_list->lock_list->list));
|
2022-03-09 16:49:16 +00:00
|
|
|
path_list->standalone_exempt_list->list = (core_aux_file_path_t*)
|
|
|
|
malloc(path_list->dir_list->size *
|
|
|
|
sizeof(*path_list->standalone_exempt_list->list));
|
2021-05-06 10:58:45 +00:00
|
|
|
|
2022-12-05 11:56:55 +00:00
|
|
|
if ( !path_list->core_list->list
|
2024-06-16 17:42:32 +00:00
|
|
|
|| !path_list->lock_list->list
|
2022-12-05 11:56:55 +00:00
|
|
|
|| !path_list->standalone_exempt_list->list)
|
2021-05-06 10:58:45 +00:00
|
|
|
goto error;
|
|
|
|
|
|
|
|
/* Parse directory listing */
|
|
|
|
for (i = 0; i < path_list->dir_list->size; i++)
|
|
|
|
{
|
|
|
|
const char *file_path = path_list->dir_list->elems[i].data;
|
|
|
|
const char *filename = NULL;
|
|
|
|
const char *file_ext = NULL;
|
|
|
|
|
2021-11-23 04:05:09 +00:00
|
|
|
if ( string_is_empty(file_path)
|
|
|
|
|| !(filename = path_basename_nocompression(file_path))
|
|
|
|
|| !(file_ext = path_get_extension(filename)))
|
2021-05-06 10:58:45 +00:00
|
|
|
continue;
|
|
|
|
|
2022-03-09 16:49:16 +00:00
|
|
|
/* Check whether this is a core, lock or
|
|
|
|
* 'standalone exempt' file */
|
2021-05-07 09:58:09 +00:00
|
|
|
if (string_list_find_elem(core_ext_list, file_ext))
|
2021-05-06 10:58:45 +00:00
|
|
|
{
|
|
|
|
path_list->core_list->list[
|
|
|
|
path_list->core_list->size].path = file_path;
|
|
|
|
path_list->core_list->list[
|
|
|
|
path_list->core_list->size].filename = filename;
|
|
|
|
path_list->core_list->size++;
|
|
|
|
}
|
|
|
|
else if (string_is_equal(file_ext, FILE_PATH_LOCK_EXTENSION_NO_DOT))
|
|
|
|
{
|
|
|
|
path_list->lock_list->list[
|
|
|
|
path_list->lock_list->size].filename = filename;
|
|
|
|
path_list->lock_list->list[
|
|
|
|
path_list->lock_list->size].hash = core_info_hash_string(filename);
|
|
|
|
path_list->lock_list->size++;
|
|
|
|
}
|
2022-03-09 16:49:16 +00:00
|
|
|
#if defined(HAVE_DYNAMIC)
|
|
|
|
else if (string_is_equal(file_ext, FILE_PATH_STANDALONE_EXEMPT_EXTENSION_NO_DOT))
|
|
|
|
{
|
|
|
|
path_list->standalone_exempt_list->list[
|
|
|
|
path_list->standalone_exempt_list->size].filename = filename;
|
|
|
|
path_list->standalone_exempt_list->list[
|
|
|
|
path_list->standalone_exempt_list->size].hash = core_info_hash_string(filename);
|
|
|
|
path_list->standalone_exempt_list->size++;
|
|
|
|
}
|
|
|
|
#endif
|
2021-05-06 10:58:45 +00:00
|
|
|
}
|
|
|
|
|
2021-05-07 09:58:09 +00:00
|
|
|
string_list_free(core_ext_list);
|
2021-05-06 10:58:45 +00:00
|
|
|
return path_list;
|
|
|
|
|
|
|
|
error:
|
2021-05-07 09:58:09 +00:00
|
|
|
string_list_free(core_ext_list);
|
2021-05-06 10:58:45 +00:00
|
|
|
core_info_path_list_free(path_list);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2021-11-23 04:05:09 +00:00
|
|
|
static bool core_info_path_is_locked(
|
2022-03-09 16:49:16 +00:00
|
|
|
core_aux_file_path_list_t *lock_list,
|
2021-05-06 10:58:45 +00:00
|
|
|
const char *core_file_name)
|
|
|
|
{
|
2022-08-04 01:44:19 +00:00
|
|
|
size_t i, len;
|
2021-05-06 10:58:45 +00:00
|
|
|
uint32_t hash;
|
2022-07-03 11:59:23 +00:00
|
|
|
char lock_filename[NAME_MAX_LENGTH];
|
2021-05-06 10:58:45 +00:00
|
|
|
|
|
|
|
if (lock_list->size < 1)
|
2016-05-09 16:11:17 +00:00
|
|
|
return false;
|
2020-06-29 01:46:27 +00:00
|
|
|
|
2023-06-20 14:33:55 +00:00
|
|
|
len = strlcpy(lock_filename, core_file_name,
|
2022-07-22 20:23:54 +00:00
|
|
|
sizeof(lock_filename));
|
2023-06-20 14:33:55 +00:00
|
|
|
strlcpy(lock_filename + len,
|
|
|
|
".lck",
|
|
|
|
sizeof(lock_filename) - len);
|
2021-05-06 10:58:45 +00:00
|
|
|
|
|
|
|
hash = core_info_hash_string(lock_filename);
|
|
|
|
|
|
|
|
for (i = 0; i < lock_list->size; i++)
|
|
|
|
{
|
2022-03-09 16:49:16 +00:00
|
|
|
core_aux_file_path_t *lock_file = &lock_list->list[i];
|
2021-05-06 10:58:45 +00:00
|
|
|
|
2022-12-05 11:56:55 +00:00
|
|
|
if ( (lock_file->hash == hash)
|
|
|
|
&& string_is_equal(lock_file->filename, lock_filename))
|
2021-05-06 10:58:45 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2022-03-09 16:49:16 +00:00
|
|
|
static bool core_info_path_is_standalone_exempt(
|
|
|
|
core_aux_file_path_list_t *exempt_list,
|
|
|
|
const char *core_file_name)
|
|
|
|
{
|
2022-08-08 20:41:32 +00:00
|
|
|
size_t i, len;
|
2022-03-09 16:49:16 +00:00
|
|
|
uint32_t hash;
|
2022-07-03 11:59:23 +00:00
|
|
|
char exempt_filename[NAME_MAX_LENGTH];
|
2022-03-09 16:49:16 +00:00
|
|
|
|
|
|
|
if (exempt_list->size < 1)
|
|
|
|
return false;
|
|
|
|
|
2023-06-20 14:33:55 +00:00
|
|
|
len = strlcpy(exempt_filename, core_file_name,
|
2022-07-22 20:23:54 +00:00
|
|
|
sizeof(exempt_filename));
|
2023-06-20 14:33:55 +00:00
|
|
|
strlcpy(exempt_filename + len,
|
|
|
|
".lsae",
|
|
|
|
sizeof(exempt_filename) - len);
|
2022-03-09 16:49:16 +00:00
|
|
|
|
|
|
|
hash = core_info_hash_string(exempt_filename);
|
|
|
|
|
|
|
|
for (i = 0; i < exempt_list->size; i++)
|
|
|
|
{
|
|
|
|
core_aux_file_path_t *exempt_file = &exempt_list->list[i];
|
|
|
|
|
2022-12-05 11:56:55 +00:00
|
|
|
if ( (exempt_file->hash == hash)
|
|
|
|
&& string_is_equal(exempt_file->filename, exempt_filename))
|
2022-03-09 16:49:16 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
static bool core_info_get_file_id(const char *core_filename,
|
|
|
|
char *core_file_id, size_t len)
|
|
|
|
{
|
|
|
|
char *last_underscore = NULL;
|
|
|
|
|
|
|
|
if (string_is_empty(core_filename))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
/* Core file 'id' is filename without extension
|
|
|
|
* or platform-specific suffix */
|
|
|
|
|
|
|
|
/* > Remove extension */
|
|
|
|
strlcpy(core_file_id, core_filename, len);
|
|
|
|
path_remove_extension(core_file_id);
|
2024-05-09 16:54:28 +00:00
|
|
|
#if IOS
|
|
|
|
/* 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. Here, we need to change it back.
|
|
|
|
*/
|
|
|
|
string_replace_all_chars(core_file_id, '.', '_');
|
|
|
|
#endif
|
2021-05-06 10:58:45 +00:00
|
|
|
|
|
|
|
/* > Remove suffix */
|
|
|
|
last_underscore = (char*)strrchr(core_file_id, '_');
|
|
|
|
|
2022-12-05 11:56:55 +00:00
|
|
|
if ( !string_is_empty(last_underscore)
|
|
|
|
&& !string_is_equal(last_underscore, "_libretro"))
|
2021-05-06 10:58:45 +00:00
|
|
|
*last_underscore = '\0';
|
|
|
|
|
|
|
|
return !string_is_empty(core_file_id);
|
|
|
|
}
|
|
|
|
|
|
|
|
static core_info_t *core_info_find_internal(
|
|
|
|
core_info_list_t *list,
|
|
|
|
const char *core_path)
|
|
|
|
{
|
|
|
|
size_t i;
|
2022-07-03 11:59:23 +00:00
|
|
|
uint32_t hash;
|
|
|
|
char core_file_id[256];
|
2021-05-06 10:58:45 +00:00
|
|
|
|
2022-12-05 11:56:55 +00:00
|
|
|
if ( !list
|
|
|
|
|| string_is_empty(core_path)
|
|
|
|
|| !core_info_get_file_id(path_basename_nocompression(core_path),
|
|
|
|
core_file_id, sizeof(core_file_id)))
|
2021-05-06 10:58:45 +00:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
hash = core_info_hash_string(core_file_id);
|
|
|
|
|
|
|
|
for (i = 0; i < list->count; i++)
|
|
|
|
{
|
|
|
|
core_info_t *info = &list->list[i];
|
|
|
|
|
2022-12-05 11:56:55 +00:00
|
|
|
if ( (info->core_file_id.hash == hash)
|
|
|
|
&& string_is_equal(info->core_file_id.str, core_file_id))
|
2021-05-06 10:58:45 +00:00
|
|
|
return info;
|
|
|
|
}
|
2016-02-07 01:24:08 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
return NULL;
|
2016-05-09 16:11:17 +00:00
|
|
|
}
|
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
static void core_info_resolve_firmware(
|
|
|
|
core_info_t *info, config_file_t *conf)
|
2016-05-09 16:11:17 +00:00
|
|
|
{
|
2021-05-06 10:58:45 +00:00
|
|
|
unsigned i;
|
2023-04-30 15:26:27 +00:00
|
|
|
size_t _len;
|
|
|
|
char prefix[12];
|
2021-05-06 10:58:45 +00:00
|
|
|
unsigned firmware_count = 0;
|
|
|
|
core_info_firmware_t *firmware = NULL;
|
2016-05-09 16:11:17 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
if (!config_get_uint(conf, "firmware_count", &firmware_count))
|
|
|
|
return;
|
2016-05-09 16:11:17 +00:00
|
|
|
|
2021-11-23 04:05:09 +00:00
|
|
|
firmware = (core_info_firmware_t*)calloc(
|
|
|
|
firmware_count, sizeof(*firmware));
|
2016-05-09 16:11:17 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
if (!firmware)
|
|
|
|
return;
|
2020-09-02 16:11:21 +00:00
|
|
|
|
2023-04-30 15:26:27 +00:00
|
|
|
_len = strlcpy(prefix, "firmware", sizeof(prefix));
|
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
for (i = 0; i < firmware_count; i++)
|
|
|
|
{
|
2023-06-18 10:06:12 +00:00
|
|
|
size_t _len2;
|
|
|
|
char key[64];
|
2021-05-06 10:58:45 +00:00
|
|
|
struct config_entry_list *entry = NULL;
|
|
|
|
bool tmp_bool = false;
|
2016-05-09 16:11:17 +00:00
|
|
|
|
2023-04-30 15:26:27 +00:00
|
|
|
snprintf(prefix + _len, sizeof(prefix) - _len, "%u_", i);
|
2023-06-18 10:06:12 +00:00
|
|
|
_len2 = strlcpy(key, prefix, sizeof(key));
|
|
|
|
strlcpy(key + _len2, "opt", sizeof(key) - _len2);
|
|
|
|
|
|
|
|
if (config_get_bool(conf, key, &tmp_bool))
|
|
|
|
firmware[i].optional = tmp_bool;
|
2018-08-15 20:10:52 +00:00
|
|
|
|
2023-06-18 10:06:12 +00:00
|
|
|
strlcpy(key + _len2, "path", sizeof(key) - _len2);
|
|
|
|
|
|
|
|
entry = config_get_entry(conf, key);
|
2016-05-09 16:11:17 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
if (entry && !string_is_empty(entry->value))
|
|
|
|
{
|
|
|
|
firmware[i].path = entry->value;
|
|
|
|
entry->value = NULL;
|
|
|
|
}
|
2016-05-09 16:11:17 +00:00
|
|
|
|
2023-06-18 10:06:12 +00:00
|
|
|
strlcpy(key + _len2, "desc", sizeof(key) - _len2);
|
|
|
|
|
|
|
|
entry = config_get_entry(conf, key);
|
2016-05-09 16:11:17 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
if (entry && !string_is_empty(entry->value))
|
|
|
|
{
|
|
|
|
firmware[i].desc = entry->value;
|
|
|
|
entry->value = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
info->firmware_count = firmware_count;
|
|
|
|
info->firmware = firmware;
|
2016-05-09 16:11:17 +00:00
|
|
|
}
|
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
static config_file_t *core_info_get_config_file(
|
2022-08-12 23:40:45 +00:00
|
|
|
const char *core_file_id, const char *info_dir)
|
2016-05-09 16:11:17 +00:00
|
|
|
{
|
2022-08-12 23:40:45 +00:00
|
|
|
if (!string_is_empty(info_dir))
|
2021-05-18 21:18:09 +00:00
|
|
|
{
|
2022-08-12 23:40:45 +00:00
|
|
|
char info_path[PATH_MAX_LENGTH];
|
|
|
|
fill_pathname_join_special(info_path, info_dir,
|
|
|
|
core_file_id, sizeof(info_path));
|
|
|
|
return config_file_new_from_path_to_string(info_path);
|
2021-05-18 21:18:09 +00:00
|
|
|
}
|
2022-08-12 23:40:45 +00:00
|
|
|
return config_file_new_from_path_to_string(core_file_id);
|
2016-05-09 16:11:17 +00:00
|
|
|
}
|
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
static void core_info_parse_config_file(
|
|
|
|
core_info_list_t *list, core_info_t *info,
|
|
|
|
config_file_t *conf)
|
2016-05-09 16:11:17 +00:00
|
|
|
{
|
2021-05-06 10:58:45 +00:00
|
|
|
bool tmp_bool = false;
|
2022-08-12 23:40:45 +00:00
|
|
|
struct config_entry_list *entry = config_get_entry(conf, "display_name");
|
2016-05-09 16:11:17 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
if (entry && !string_is_empty(entry->value))
|
|
|
|
{
|
|
|
|
info->display_name = entry->value;
|
|
|
|
entry->value = NULL;
|
|
|
|
}
|
2016-05-09 16:11:17 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
entry = config_get_entry(conf, "display_version");
|
2016-05-09 16:11:17 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
if (entry && !string_is_empty(entry->value))
|
|
|
|
{
|
|
|
|
info->display_version = entry->value;
|
|
|
|
entry->value = NULL;
|
|
|
|
}
|
2016-05-09 16:11:17 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
entry = config_get_entry(conf, "corename");
|
2016-05-09 16:11:17 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
if (entry && !string_is_empty(entry->value))
|
|
|
|
{
|
|
|
|
info->core_name = entry->value;
|
|
|
|
entry->value = NULL;
|
|
|
|
}
|
2016-05-09 16:11:17 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
entry = config_get_entry(conf, "systemname");
|
2016-05-09 16:11:17 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
if (entry && !string_is_empty(entry->value))
|
2016-05-09 16:11:17 +00:00
|
|
|
{
|
2021-05-06 10:58:45 +00:00
|
|
|
info->systemname = entry->value;
|
|
|
|
entry->value = NULL;
|
|
|
|
}
|
2016-05-09 16:11:17 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
entry = config_get_entry(conf, "systemid");
|
2016-05-09 16:11:17 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
if (entry && !string_is_empty(entry->value))
|
|
|
|
{
|
|
|
|
info->system_id = entry->value;
|
|
|
|
entry->value = NULL;
|
|
|
|
}
|
2016-05-09 16:11:17 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
entry = config_get_entry(conf, "manufacturer");
|
|
|
|
|
|
|
|
if (entry && !string_is_empty(entry->value))
|
|
|
|
{
|
|
|
|
info->system_manufacturer = entry->value;
|
|
|
|
entry->value = NULL;
|
2016-05-09 16:11:17 +00:00
|
|
|
}
|
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
entry = config_get_entry(conf, "supported_extensions");
|
2016-05-09 16:11:17 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
if (entry && !string_is_empty(entry->value))
|
|
|
|
{
|
|
|
|
info->supported_extensions = entry->value;
|
|
|
|
entry->value = NULL;
|
2016-05-09 16:11:17 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
info->supported_extensions_list =
|
|
|
|
string_split(info->supported_extensions, "|");
|
|
|
|
}
|
2021-04-26 13:24:24 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
entry = config_get_entry(conf, "authors");
|
2021-04-26 13:24:24 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
if (entry && !string_is_empty(entry->value))
|
|
|
|
{
|
|
|
|
info->authors = entry->value;
|
|
|
|
entry->value = NULL;
|
2020-07-23 18:08:43 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
info->authors_list =
|
|
|
|
string_split(info->authors, "|");
|
|
|
|
}
|
2016-05-09 16:11:17 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
entry = config_get_entry(conf, "permissions");
|
2017-11-09 00:59:52 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
if (entry && !string_is_empty(entry->value))
|
|
|
|
{
|
|
|
|
info->permissions = entry->value;
|
|
|
|
entry->value = NULL;
|
2017-11-09 00:59:52 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
info->permissions_list =
|
|
|
|
string_split(info->permissions, "|");
|
|
|
|
}
|
2017-11-09 00:59:52 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
entry = config_get_entry(conf, "license");
|
2021-04-20 17:46:11 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
if (entry && !string_is_empty(entry->value))
|
2017-11-09 00:59:52 +00:00
|
|
|
{
|
2021-05-06 10:58:45 +00:00
|
|
|
info->licenses = entry->value;
|
|
|
|
entry->value = NULL;
|
2017-11-09 00:59:52 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
info->licenses_list =
|
|
|
|
string_split(info->licenses, "|");
|
|
|
|
}
|
2017-11-09 00:59:52 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
entry = config_get_entry(conf, "categories");
|
2017-11-09 00:59:52 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
if (entry && !string_is_empty(entry->value))
|
|
|
|
{
|
|
|
|
info->categories = entry->value;
|
|
|
|
entry->value = NULL;
|
2017-11-09 00:59:52 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
info->categories_list =
|
|
|
|
string_split(info->categories, "|");
|
2017-11-09 00:59:52 +00:00
|
|
|
}
|
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
entry = config_get_entry(conf, "database");
|
2016-10-03 20:08:55 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
if (entry && !string_is_empty(entry->value))
|
|
|
|
{
|
|
|
|
info->databases = entry->value;
|
|
|
|
entry->value = NULL;
|
2016-10-03 20:08:55 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
info->databases_list =
|
|
|
|
string_split(info->databases, "|");
|
|
|
|
}
|
2016-10-03 20:08:55 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
entry = config_get_entry(conf, "notes");
|
2021-04-20 17:46:11 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
if (entry && !string_is_empty(entry->value))
|
2017-03-05 17:47:02 +00:00
|
|
|
{
|
2021-05-06 10:58:45 +00:00
|
|
|
info->notes = entry->value;
|
|
|
|
entry->value = NULL;
|
2017-02-28 10:16:05 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
info->note_list =
|
|
|
|
string_split(info->notes, "|");
|
|
|
|
}
|
2016-10-12 20:14:00 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
entry = config_get_entry(conf, "required_hw_api");
|
2016-12-14 00:16:10 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
if (entry && !string_is_empty(entry->value))
|
|
|
|
{
|
|
|
|
info->required_hw_api = entry->value;
|
|
|
|
entry->value = NULL;
|
2016-12-14 00:16:10 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
info->required_hw_api_list =
|
|
|
|
string_split(info->required_hw_api, "|");
|
2016-10-03 20:08:55 +00:00
|
|
|
}
|
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
entry = config_get_entry(conf, "description");
|
2016-05-09 16:11:17 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
if (entry && !string_is_empty(entry->value))
|
2016-02-07 01:18:26 +00:00
|
|
|
{
|
2021-05-06 10:58:45 +00:00
|
|
|
info->description = entry->value;
|
|
|
|
entry->value = NULL;
|
2016-02-07 01:18:26 +00:00
|
|
|
}
|
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
if (config_get_bool(conf, "supports_no_game",
|
|
|
|
&tmp_bool))
|
|
|
|
info->supports_no_game = tmp_bool;
|
2016-05-09 16:11:17 +00:00
|
|
|
|
2022-02-22 18:23:48 +00:00
|
|
|
if (config_get_bool(conf, "single_purpose",
|
|
|
|
&tmp_bool))
|
|
|
|
info->single_purpose = tmp_bool;
|
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
if (config_get_bool(conf, "database_match_archive_member",
|
|
|
|
&tmp_bool))
|
|
|
|
info->database_match_archive_member = tmp_bool;
|
2020-05-27 16:00:47 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
if (config_get_bool(conf, "is_experimental",
|
|
|
|
&tmp_bool))
|
|
|
|
info->is_experimental = tmp_bool;
|
2020-05-27 16:00:47 +00:00
|
|
|
|
2022-02-02 15:49:53 +00:00
|
|
|
|
|
|
|
/* Savestate support level is slightly more complex,
|
|
|
|
* since it is a value derived from two configuration
|
|
|
|
* parameters */
|
|
|
|
|
|
|
|
/* > Assume all cores have 'full' savestate support
|
|
|
|
* by default */
|
|
|
|
info->savestate_support_level =
|
|
|
|
CORE_INFO_SAVESTATE_DETERMINISTIC;
|
|
|
|
|
|
|
|
/* > Check whether savestate functionality is defined
|
|
|
|
* in the info file */
|
|
|
|
if (config_get_bool(conf, "savestate", &tmp_bool))
|
|
|
|
{
|
|
|
|
if (tmp_bool)
|
|
|
|
{
|
|
|
|
/* Check if savestate features are defined */
|
|
|
|
entry = config_get_entry(conf, "savestate_features");
|
|
|
|
|
|
|
|
if (entry && !string_is_empty(entry->value))
|
|
|
|
{
|
|
|
|
if (string_is_equal(entry->value, "basic"))
|
|
|
|
info->savestate_support_level =
|
|
|
|
CORE_INFO_SAVESTATE_BASIC;
|
|
|
|
else if (string_is_equal(entry->value, "serialized"))
|
|
|
|
info->savestate_support_level =
|
|
|
|
CORE_INFO_SAVESTATE_SERIALIZED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
info->savestate_support_level =
|
|
|
|
CORE_INFO_SAVESTATE_DISABLED;
|
|
|
|
}
|
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
core_info_resolve_firmware(info, conf);
|
2020-05-27 16:00:47 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
info->has_info = true;
|
|
|
|
list->info_count++;
|
|
|
|
}
|
2020-05-27 16:00:47 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
static void core_info_list_resolve_all_extensions(
|
|
|
|
core_info_list_t *core_info_list)
|
|
|
|
{
|
|
|
|
size_t i = 0;
|
|
|
|
size_t all_ext_len = 0;
|
|
|
|
char *all_ext = NULL;
|
2020-05-27 16:00:47 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
for (i = 0; i < core_info_list->count; i++)
|
|
|
|
{
|
|
|
|
if (core_info_list->list[i].supported_extensions)
|
|
|
|
all_ext_len +=
|
|
|
|
(strlen(core_info_list->list[i].supported_extensions) + 2);
|
|
|
|
}
|
2020-05-27 16:00:47 +00:00
|
|
|
|
2022-12-05 12:24:47 +00:00
|
|
|
all_ext_len += STRLEN_CONST("7z|") + STRLEN_CONST("zip|");
|
2022-08-08 20:41:32 +00:00
|
|
|
if (!(all_ext = (char*)calloc(1, all_ext_len)))
|
2021-05-06 10:58:45 +00:00
|
|
|
return;
|
2020-05-27 16:00:47 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
core_info_list->all_ext = all_ext;
|
2020-05-27 16:00:47 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
for (i = 0; i < core_info_list->count; i++)
|
2021-04-26 13:24:24 +00:00
|
|
|
{
|
2024-06-16 17:42:32 +00:00
|
|
|
size_t _len;
|
2021-05-06 10:58:45 +00:00
|
|
|
if (!core_info_list->list[i].supported_extensions)
|
|
|
|
continue;
|
|
|
|
|
2024-06-16 17:42:32 +00:00
|
|
|
_len = strlcat(core_info_list->all_ext,
|
2021-05-06 10:58:45 +00:00
|
|
|
core_info_list->list[i].supported_extensions, all_ext_len);
|
2024-06-16 17:42:32 +00:00
|
|
|
strlcpy(core_info_list->all_ext + _len, "|", all_ext_len - _len);
|
2021-04-26 13:24:24 +00:00
|
|
|
}
|
2021-05-06 10:58:45 +00:00
|
|
|
#ifdef HAVE_7ZIP
|
2022-12-05 12:24:47 +00:00
|
|
|
strlcat(core_info_list->all_ext, "7z|", all_ext_len);
|
2021-05-06 10:58:45 +00:00
|
|
|
#endif
|
|
|
|
#ifdef HAVE_ZLIB
|
2022-12-05 12:24:47 +00:00
|
|
|
strlcat(core_info_list->all_ext, "zip|", all_ext_len);
|
2021-05-06 10:58:45 +00:00
|
|
|
#endif
|
|
|
|
}
|
2020-05-27 16:00:47 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
static void core_info_free(core_info_t* info)
|
|
|
|
{
|
|
|
|
size_t i;
|
2020-05-27 16:00:47 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
free(info->path);
|
|
|
|
free(info->core_name);
|
|
|
|
free(info->systemname);
|
|
|
|
free(info->system_id);
|
|
|
|
free(info->system_manufacturer);
|
|
|
|
free(info->display_name);
|
|
|
|
free(info->display_version);
|
|
|
|
free(info->supported_extensions);
|
|
|
|
free(info->authors);
|
|
|
|
free(info->permissions);
|
|
|
|
free(info->licenses);
|
|
|
|
free(info->categories);
|
|
|
|
free(info->databases);
|
|
|
|
free(info->notes);
|
|
|
|
free(info->required_hw_api);
|
|
|
|
free(info->description);
|
|
|
|
string_list_free(info->supported_extensions_list);
|
|
|
|
string_list_free(info->authors_list);
|
|
|
|
string_list_free(info->note_list);
|
|
|
|
string_list_free(info->permissions_list);
|
|
|
|
string_list_free(info->licenses_list);
|
|
|
|
string_list_free(info->categories_list);
|
|
|
|
string_list_free(info->databases_list);
|
|
|
|
string_list_free(info->required_hw_api_list);
|
|
|
|
|
|
|
|
for (i = 0; i < info->firmware_count; i++)
|
2021-04-26 13:24:24 +00:00
|
|
|
{
|
2022-03-05 13:39:56 +00:00
|
|
|
if (info->firmware[i].path)
|
|
|
|
free(info->firmware[i].path);
|
|
|
|
if (info->firmware[i].desc)
|
|
|
|
free(info->firmware[i].desc);
|
|
|
|
info->firmware[i].path = NULL;
|
|
|
|
info->firmware[i].desc = NULL;
|
2021-04-26 13:24:24 +00:00
|
|
|
}
|
2021-05-06 10:58:45 +00:00
|
|
|
free(info->firmware);
|
2020-05-27 16:00:47 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
free(info->core_file_id.str);
|
|
|
|
}
|
2020-05-27 16:00:47 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
static void core_info_list_free(core_info_list_t *core_info_list)
|
|
|
|
{
|
|
|
|
size_t i;
|
|
|
|
|
|
|
|
if (!core_info_list)
|
|
|
|
return;
|
|
|
|
|
|
|
|
for (i = 0; i < core_info_list->count; i++)
|
2021-04-26 13:24:24 +00:00
|
|
|
{
|
2021-05-06 10:58:45 +00:00
|
|
|
core_info_t *info = (core_info_t*)&core_info_list->list[i];
|
|
|
|
core_info_free(info);
|
2021-04-26 13:24:24 +00:00
|
|
|
}
|
2020-05-27 16:00:47 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
free(core_info_list->all_ext);
|
|
|
|
free(core_info_list->list);
|
|
|
|
free(core_info_list);
|
2020-05-27 16:00:47 +00:00
|
|
|
}
|
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
static core_info_list_t *core_info_list_new(const char *path,
|
|
|
|
const char *libretro_info_dir,
|
|
|
|
const char *exts,
|
|
|
|
bool dir_show_hidden_files,
|
2021-07-19 15:37:07 +00:00
|
|
|
bool enable_cache,
|
|
|
|
bool *cache_supported)
|
2020-05-27 16:00:47 +00:00
|
|
|
{
|
2021-05-06 10:58:45 +00:00
|
|
|
size_t i;
|
|
|
|
core_info_t *core_info = NULL;
|
|
|
|
core_info_list_t *core_info_list = NULL;
|
|
|
|
core_info_cache_list_t *core_info_cache_list = NULL;
|
|
|
|
const char *info_dir = libretro_info_dir;
|
2021-11-23 04:05:09 +00:00
|
|
|
core_path_list_t *path_list = core_info_path_list_new(
|
|
|
|
path, exts, dir_show_hidden_files);
|
2021-05-06 10:58:45 +00:00
|
|
|
if (!path_list)
|
|
|
|
goto error;
|
2020-05-27 16:00:47 +00:00
|
|
|
|
2022-08-01 19:31:45 +00:00
|
|
|
if (!(core_info_list = (core_info_list_t*)malloc(sizeof(*core_info_list))))
|
2021-05-06 10:58:45 +00:00
|
|
|
goto error;
|
2020-05-27 16:00:47 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
core_info_list->list = NULL;
|
|
|
|
core_info_list->count = 0;
|
|
|
|
core_info_list->info_count = 0;
|
|
|
|
core_info_list->all_ext = NULL;
|
2020-05-27 16:00:47 +00:00
|
|
|
|
2022-08-01 19:31:45 +00:00
|
|
|
if (!(core_info = (core_info_t*)calloc(path_list->core_list->size,
|
|
|
|
sizeof(*core_info))))
|
2021-05-06 10:58:45 +00:00
|
|
|
{
|
|
|
|
core_info_list_free(core_info_list);
|
|
|
|
goto error;
|
|
|
|
}
|
2020-06-26 16:40:26 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
core_info_list->list = core_info;
|
|
|
|
core_info_list->count = path_list->core_list->size;
|
2020-06-26 16:40:26 +00:00
|
|
|
|
2021-10-14 13:57:28 +00:00
|
|
|
#ifdef HAVE_CORE_INFO_CACHE
|
2021-08-23 10:47:08 +00:00
|
|
|
/* Read core info cache, if enabled */
|
2021-05-06 10:58:45 +00:00
|
|
|
if (enable_cache)
|
|
|
|
{
|
2024-09-09 13:22:08 +00:00
|
|
|
if (!(core_info_cache_list = core_info_cache_read(info_dir)))
|
2021-05-06 10:58:45 +00:00
|
|
|
goto error;
|
|
|
|
}
|
2021-10-14 13:57:28 +00:00
|
|
|
#endif
|
2020-06-26 16:40:26 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
for (i = 0; i < path_list->core_list->size; i++)
|
|
|
|
{
|
|
|
|
core_info_t *info = &core_info[i];
|
|
|
|
core_file_path_t *core_file = &path_list->core_list->list[i];
|
|
|
|
const char *base_path = core_file->path;
|
|
|
|
const char *core_filename = core_file->filename;
|
|
|
|
config_file_t *conf = NULL;
|
|
|
|
char core_file_id[256];
|
2020-06-26 16:40:26 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
if (!core_info_get_file_id(core_filename, core_file_id,
|
|
|
|
sizeof(core_file_id)))
|
|
|
|
continue;
|
2020-06-26 16:40:26 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
/* If info cache is available, search for
|
|
|
|
* current core */
|
|
|
|
if (core_info_cache_list)
|
|
|
|
{
|
2021-11-23 04:05:09 +00:00
|
|
|
core_info_t *info_cache = core_info_cache_find(
|
|
|
|
core_info_cache_list, core_file_id);
|
2020-06-26 16:40:26 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
if (info_cache)
|
|
|
|
{
|
|
|
|
core_info_copy(info_cache, info);
|
2022-03-09 16:49:16 +00:00
|
|
|
|
2021-08-23 10:47:08 +00:00
|
|
|
/* Core path is 'dynamic', and cannot
|
|
|
|
* be cached (i.e. core directory may
|
|
|
|
* change between runs) */
|
|
|
|
if (info->path)
|
|
|
|
free(info->path);
|
2022-03-09 16:49:16 +00:00
|
|
|
info->path = strdup(base_path);
|
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
/* Core lock status is 'dynamic', and
|
|
|
|
* cannot be cached */
|
2021-11-23 04:05:09 +00:00
|
|
|
info->is_locked = core_info_path_is_locked(
|
|
|
|
path_list->lock_list, core_filename);
|
2022-03-09 16:49:16 +00:00
|
|
|
|
|
|
|
/* Core 'standalone exempt' status is 'dynamic',
|
|
|
|
* and cannot be cached
|
|
|
|
* > It is also dependent upon whether the core
|
|
|
|
* supports contentless operation */
|
|
|
|
info->is_standalone_exempt = info->supports_no_game &&
|
|
|
|
core_info_path_is_standalone_exempt(
|
|
|
|
path_list->standalone_exempt_list,
|
|
|
|
core_filename);
|
|
|
|
|
2021-05-22 14:25:05 +00:00
|
|
|
/* 'info_count' is normally incremented inside
|
|
|
|
* core_info_parse_config_file(). If core entry
|
|
|
|
* is cached, must instead increment the value
|
|
|
|
* here */
|
|
|
|
if (info->has_info)
|
|
|
|
core_info_list->info_count++;
|
2022-03-09 16:49:16 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
2020-06-26 16:40:26 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
/* Cache core path */
|
2022-08-01 19:31:45 +00:00
|
|
|
info->path = strdup(base_path);
|
2020-06-26 16:40:26 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
/* Get core lock status */
|
2021-11-23 04:05:09 +00:00
|
|
|
info->is_locked = core_info_path_is_locked(
|
|
|
|
path_list->lock_list, core_filename);
|
2020-06-26 16:40:26 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
/* Cache core file 'id' */
|
|
|
|
info->core_file_id.str = strdup(core_file_id);
|
|
|
|
info->core_file_id.hash = core_info_hash_string(core_file_id);
|
2020-06-26 16:40:26 +00:00
|
|
|
|
2022-08-12 23:40:45 +00:00
|
|
|
strlcat(core_file_id, ".info", sizeof(core_file_id));
|
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
/* Parse core info file */
|
2022-08-01 19:31:45 +00:00
|
|
|
if ((conf = core_info_get_config_file(core_file_id, info_dir)))
|
2021-05-06 10:58:45 +00:00
|
|
|
{
|
|
|
|
core_info_parse_config_file(core_info_list, info, conf);
|
|
|
|
config_file_free(conf);
|
|
|
|
}
|
2019-06-26 16:40:00 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
/* Get fallback display name, if required */
|
|
|
|
if (!info->display_name)
|
|
|
|
info->display_name = strdup(core_filename);
|
2019-06-26 16:40:00 +00:00
|
|
|
|
2022-03-09 16:49:16 +00:00
|
|
|
/* Get core 'standalone exempt' status */
|
|
|
|
info->is_standalone_exempt = info->supports_no_game &&
|
|
|
|
core_info_path_is_standalone_exempt(
|
|
|
|
path_list->standalone_exempt_list,
|
|
|
|
core_filename);
|
|
|
|
|
|
|
|
info->is_installed = true;
|
2019-07-24 02:44:45 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
/* If info cache is enabled and we reach this
|
|
|
|
* point, current core is uncached
|
|
|
|
* > Add it to the list, and trigger a cache
|
|
|
|
* refresh */
|
|
|
|
if (core_info_cache_list)
|
|
|
|
{
|
|
|
|
core_info_cache_add(core_info_cache_list, info, false);
|
|
|
|
core_info_cache_list->refresh = true;
|
|
|
|
}
|
2020-06-26 16:40:26 +00:00
|
|
|
}
|
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
core_info_list_resolve_all_extensions(core_info_list);
|
2019-07-24 02:44:45 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
/* If info cache is enabled
|
|
|
|
* > Check whether any cached cores have been
|
|
|
|
* uninstalled since the last run (triggers
|
|
|
|
* a refresh)
|
|
|
|
* > Write new cache to disk if updates are
|
|
|
|
* required */
|
2021-07-19 15:37:07 +00:00
|
|
|
*cache_supported = true;
|
2021-05-06 10:58:45 +00:00
|
|
|
if (core_info_cache_list)
|
2019-07-24 02:44:45 +00:00
|
|
|
{
|
2021-05-06 10:58:45 +00:00
|
|
|
core_info_check_uninstalled(core_info_cache_list);
|
2019-07-24 02:44:45 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
if (core_info_cache_list->refresh)
|
2021-07-19 15:37:07 +00:00
|
|
|
*cache_supported = core_info_cache_write(
|
|
|
|
core_info_cache_list, info_dir);
|
2019-07-24 02:44:45 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
core_info_cache_list_free(core_info_cache_list);
|
|
|
|
}
|
2019-07-24 02:44:45 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
core_info_path_list_free(path_list);
|
|
|
|
return core_info_list;
|
2019-07-24 02:44:45 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
error:
|
|
|
|
core_info_path_list_free(path_list);
|
|
|
|
return NULL;
|
|
|
|
}
|
2019-07-24 02:44:45 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
/* Shallow-copies internal state.
|
|
|
|
*
|
|
|
|
* Data in *info is invalidated when the
|
|
|
|
* core_info_list is freed. */
|
|
|
|
bool core_info_list_get_info(core_info_list_t *core_info_list,
|
|
|
|
core_info_t *out_info, const char *core_path)
|
|
|
|
{
|
2022-12-05 11:56:55 +00:00
|
|
|
if (out_info)
|
|
|
|
{
|
|
|
|
core_info_t *info = core_info_find_internal(
|
|
|
|
core_info_list, core_path);
|
2019-07-24 02:44:45 +00:00
|
|
|
|
2022-12-05 11:56:55 +00:00
|
|
|
memset(out_info, 0, sizeof(*out_info));
|
2020-07-26 21:11:53 +00:00
|
|
|
|
2022-12-05 11:56:55 +00:00
|
|
|
if (info)
|
|
|
|
{
|
|
|
|
*out_info = *info;
|
|
|
|
return true;
|
|
|
|
}
|
2021-05-06 10:58:45 +00:00
|
|
|
}
|
2019-07-24 02:44:45 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
return false;
|
|
|
|
}
|
2019-07-24 02:44:45 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
#ifdef HAVE_COMPRESSION
|
|
|
|
static bool core_info_does_support_any_file(const core_info_t *core,
|
|
|
|
const struct string_list *list)
|
|
|
|
{
|
|
|
|
size_t i;
|
|
|
|
if (!list || !core || !core->supported_extensions_list)
|
|
|
|
return false;
|
2019-07-24 02:44:45 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
for (i = 0; i < list->size; i++)
|
|
|
|
if (string_list_find_elem_prefix(core->supported_extensions_list,
|
|
|
|
".", path_get_extension(list->elems[i].data)))
|
|
|
|
return true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
#endif
|
2019-07-24 02:44:45 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
static bool core_info_does_support_file(
|
|
|
|
const core_info_t *core, const char *path)
|
|
|
|
{
|
|
|
|
if (!core || !core->supported_extensions_list)
|
|
|
|
return false;
|
|
|
|
if (string_is_empty(path))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return string_list_find_elem_prefix(
|
|
|
|
core->supported_extensions_list, ".", path_get_extension(path));
|
|
|
|
}
|
|
|
|
|
|
|
|
/* qsort_r() is not in standard C, sadly. */
|
|
|
|
|
|
|
|
static int core_info_qsort_cmp(const void *a_, const void *b_)
|
|
|
|
{
|
2021-09-20 13:43:27 +00:00
|
|
|
core_info_state_t *p_coreinfo = &core_info_st;
|
2021-05-06 10:58:45 +00:00
|
|
|
const core_info_t *a = (const core_info_t*)a_;
|
|
|
|
const core_info_t *b = (const core_info_t*)b_;
|
|
|
|
int support_a = core_info_does_support_file(a,
|
|
|
|
p_coreinfo->tmp_path);
|
|
|
|
int support_b = core_info_does_support_file(b,
|
|
|
|
p_coreinfo->tmp_path);
|
|
|
|
#ifdef HAVE_COMPRESSION
|
|
|
|
support_a = support_a ||
|
|
|
|
core_info_does_support_any_file(a, p_coreinfo->tmp_list);
|
|
|
|
support_b = support_b ||
|
|
|
|
core_info_does_support_any_file(b, p_coreinfo->tmp_list);
|
2019-07-24 02:44:45 +00:00
|
|
|
#endif
|
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
if (support_a != support_b)
|
|
|
|
return support_b - support_a;
|
|
|
|
return strcasecmp(a->display_name, b->display_name);
|
|
|
|
}
|
2019-07-24 02:44:45 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
static bool core_info_list_update_missing_firmware_internal(
|
|
|
|
core_info_list_t *core_info_list,
|
|
|
|
const char *core_path,
|
|
|
|
const char *systemdir,
|
|
|
|
bool *set_missing_bios)
|
|
|
|
{
|
|
|
|
size_t i;
|
|
|
|
char path[PATH_MAX_LENGTH];
|
|
|
|
core_info_t *info = NULL;
|
2019-07-24 02:44:45 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
if (!core_info_list)
|
|
|
|
return false;
|
2019-07-24 02:44:45 +00:00
|
|
|
|
2022-08-01 19:31:45 +00:00
|
|
|
if (!(info = core_info_find_internal(
|
|
|
|
core_info_list, core_path)))
|
2021-05-06 10:58:45 +00:00
|
|
|
return false;
|
2019-07-24 02:44:45 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
for (i = 0; i < info->firmware_count; i++)
|
|
|
|
{
|
|
|
|
if (string_is_empty(info->firmware[i].path))
|
|
|
|
continue;
|
2019-07-24 02:44:45 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
fill_pathname_join(path, systemdir,
|
|
|
|
info->firmware[i].path, sizeof(path));
|
|
|
|
info->firmware[i].missing = !path_is_valid(path);
|
|
|
|
if (info->firmware[i].missing && !info->firmware[i].optional)
|
|
|
|
*set_missing_bios = true;
|
|
|
|
}
|
2019-07-24 02:44:45 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
return true;
|
|
|
|
}
|
2019-07-24 02:44:45 +00:00
|
|
|
|
2021-09-20 13:43:27 +00:00
|
|
|
void core_info_free_current_core(void)
|
2021-05-06 10:58:45 +00:00
|
|
|
{
|
2021-09-20 13:43:27 +00:00
|
|
|
core_info_state_t *p_coreinfo = &core_info_st;
|
2021-05-06 10:58:45 +00:00
|
|
|
if (p_coreinfo->current)
|
|
|
|
free(p_coreinfo->current);
|
|
|
|
p_coreinfo->current = NULL;
|
|
|
|
}
|
2020-07-26 06:22:04 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
bool core_info_init_current_core(void)
|
|
|
|
{
|
2021-09-20 13:43:27 +00:00
|
|
|
core_info_state_t *p_coreinfo = &core_info_st;
|
2021-05-06 10:58:45 +00:00
|
|
|
core_info_t *current = (core_info_t*)
|
|
|
|
malloc(sizeof(*current));
|
|
|
|
if (!current)
|
|
|
|
return false;
|
|
|
|
current->has_info = false;
|
|
|
|
current->supports_no_game = false;
|
2022-02-22 18:23:48 +00:00
|
|
|
current->single_purpose = false;
|
2021-05-06 10:58:45 +00:00
|
|
|
current->database_match_archive_member = false;
|
|
|
|
current->is_experimental = false;
|
|
|
|
current->is_locked = false;
|
2022-03-09 16:49:16 +00:00
|
|
|
current->is_standalone_exempt = false;
|
|
|
|
current->is_installed = false;
|
2021-05-06 10:58:45 +00:00
|
|
|
current->firmware_count = 0;
|
2022-02-02 15:49:53 +00:00
|
|
|
current->savestate_support_level = CORE_INFO_SAVESTATE_DETERMINISTIC;
|
2021-05-06 10:58:45 +00:00
|
|
|
current->path = NULL;
|
|
|
|
current->display_name = NULL;
|
|
|
|
current->display_version = NULL;
|
|
|
|
current->core_name = NULL;
|
|
|
|
current->system_manufacturer = NULL;
|
|
|
|
current->systemname = NULL;
|
|
|
|
current->system_id = NULL;
|
|
|
|
current->supported_extensions = NULL;
|
|
|
|
current->authors = NULL;
|
|
|
|
current->permissions = NULL;
|
|
|
|
current->licenses = NULL;
|
|
|
|
current->categories = NULL;
|
|
|
|
current->databases = NULL;
|
|
|
|
current->notes = NULL;
|
|
|
|
current->required_hw_api = NULL;
|
|
|
|
current->description = NULL;
|
|
|
|
current->categories_list = NULL;
|
|
|
|
current->databases_list = NULL;
|
|
|
|
current->note_list = NULL;
|
|
|
|
current->supported_extensions_list = NULL;
|
|
|
|
current->authors_list = NULL;
|
|
|
|
current->permissions_list = NULL;
|
|
|
|
current->licenses_list = NULL;
|
|
|
|
current->required_hw_api_list = NULL;
|
|
|
|
current->firmware = NULL;
|
|
|
|
current->core_file_id.str = NULL;
|
|
|
|
current->core_file_id.hash = 0;
|
2019-07-24 02:44:45 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
p_coreinfo->current = current;
|
|
|
|
return true;
|
|
|
|
}
|
2019-07-24 02:44:45 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
bool core_info_get_current_core(core_info_t **core)
|
|
|
|
{
|
2021-09-20 13:43:27 +00:00
|
|
|
core_info_state_t *p_coreinfo = &core_info_st;
|
2021-05-06 10:58:45 +00:00
|
|
|
if (!core)
|
|
|
|
return false;
|
|
|
|
*core = p_coreinfo->current;
|
2019-07-29 20:30:53 +00:00
|
|
|
return true;
|
2019-07-24 02:44:45 +00:00
|
|
|
}
|
2020-06-18 16:08:57 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
void core_info_deinit_list(void)
|
2020-06-18 16:08:57 +00:00
|
|
|
{
|
2021-09-20 13:43:27 +00:00
|
|
|
core_info_state_t *p_coreinfo = &core_info_st;
|
2021-05-06 10:58:45 +00:00
|
|
|
if (p_coreinfo->curr_list)
|
|
|
|
core_info_list_free(p_coreinfo->curr_list);
|
|
|
|
p_coreinfo->curr_list = NULL;
|
|
|
|
}
|
2020-06-18 16:08:57 +00:00
|
|
|
|
2021-11-23 04:05:09 +00:00
|
|
|
bool core_info_init_list(
|
|
|
|
const char *path_info, const char *dir_cores,
|
|
|
|
const char *exts, bool dir_show_hidden_files,
|
2021-07-19 15:37:07 +00:00
|
|
|
bool enable_cache, bool *cache_supported)
|
2021-05-06 10:58:45 +00:00
|
|
|
{
|
2021-09-20 13:43:27 +00:00
|
|
|
core_info_state_t *p_coreinfo = &core_info_st;
|
|
|
|
if (!(p_coreinfo->curr_list = core_info_list_new(
|
|
|
|
dir_cores,
|
2024-06-16 17:42:32 +00:00
|
|
|
!string_is_empty(path_info)
|
|
|
|
? path_info
|
2021-09-20 13:43:57 +00:00
|
|
|
: dir_cores,
|
2021-05-06 10:58:45 +00:00
|
|
|
exts,
|
|
|
|
dir_show_hidden_files,
|
2021-07-19 15:37:07 +00:00
|
|
|
enable_cache,
|
|
|
|
cache_supported)))
|
2021-05-06 10:58:45 +00:00
|
|
|
return false;
|
|
|
|
return true;
|
|
|
|
}
|
2020-08-27 10:10:14 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
bool core_info_get_list(core_info_list_t **core)
|
|
|
|
{
|
2021-09-20 13:43:27 +00:00
|
|
|
core_info_state_t *p_coreinfo = &core_info_st;
|
2021-05-06 10:58:45 +00:00
|
|
|
if (!core)
|
2020-08-28 15:27:48 +00:00
|
|
|
return false;
|
2021-05-06 10:58:45 +00:00
|
|
|
*core = p_coreinfo->curr_list;
|
|
|
|
return true;
|
|
|
|
}
|
2020-08-28 15:27:48 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
/* Returns number of installed cores */
|
|
|
|
size_t core_info_count(void)
|
|
|
|
{
|
2021-09-20 13:43:27 +00:00
|
|
|
core_info_state_t *p_coreinfo = &core_info_st;
|
2022-08-01 19:31:45 +00:00
|
|
|
if (p_coreinfo && p_coreinfo->curr_list)
|
|
|
|
return p_coreinfo->curr_list->count;
|
|
|
|
return 0;
|
2021-05-06 10:58:45 +00:00
|
|
|
}
|
|
|
|
|
2021-11-23 04:05:09 +00:00
|
|
|
bool core_info_list_update_missing_firmware(
|
|
|
|
core_info_ctx_firmware_t *info, bool *set_missing_bios)
|
2021-05-06 10:58:45 +00:00
|
|
|
{
|
2021-09-20 13:43:27 +00:00
|
|
|
core_info_state_t *p_coreinfo = &core_info_st;
|
2022-08-01 19:31:45 +00:00
|
|
|
if (info)
|
|
|
|
return core_info_list_update_missing_firmware_internal(
|
|
|
|
p_coreinfo->curr_list,
|
|
|
|
info->path, info->directory.system,
|
|
|
|
set_missing_bios);
|
|
|
|
return false;
|
2021-05-06 10:58:45 +00:00
|
|
|
}
|
2020-06-18 16:08:57 +00:00
|
|
|
|
2021-09-20 13:43:27 +00:00
|
|
|
bool core_info_load(const char *core_path)
|
2021-05-06 10:58:45 +00:00
|
|
|
{
|
2021-09-20 13:43:27 +00:00
|
|
|
core_info_state_t *p_coreinfo = &core_info_st;
|
2021-05-06 10:58:45 +00:00
|
|
|
core_info_t *core_info = NULL;
|
|
|
|
|
|
|
|
if (!p_coreinfo->current)
|
|
|
|
core_info_init_current_core();
|
|
|
|
|
|
|
|
core_info_get_current_core(&core_info);
|
|
|
|
|
|
|
|
if (!p_coreinfo->curr_list)
|
2020-08-26 18:22:56 +00:00
|
|
|
return false;
|
2020-06-18 16:08:57 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
if (!core_info_list_get_info(p_coreinfo->curr_list,
|
|
|
|
core_info, core_path))
|
2020-08-26 18:22:56 +00:00
|
|
|
return false;
|
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
return true;
|
|
|
|
}
|
2020-06-18 16:08:57 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
bool core_info_find(const char *core_path,
|
|
|
|
core_info_t **core_info)
|
|
|
|
{
|
2021-09-20 13:43:27 +00:00
|
|
|
core_info_state_t *p_coreinfo = &core_info_st;
|
2021-05-06 10:58:45 +00:00
|
|
|
core_info_t *info = NULL;
|
2020-06-18 16:08:57 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
if (!core_info || !p_coreinfo->curr_list)
|
|
|
|
return false;
|
2020-06-18 16:08:57 +00:00
|
|
|
|
2022-08-01 19:31:45 +00:00
|
|
|
if (!(info = core_info_find_internal(p_coreinfo->curr_list, core_path)))
|
2021-05-06 10:58:45 +00:00
|
|
|
return false;
|
2020-06-18 16:08:57 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
*core_info = info;
|
|
|
|
return true;
|
|
|
|
}
|
2020-06-18 16:08:57 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
core_info_t *core_info_get(core_info_list_t *list, size_t i)
|
|
|
|
{
|
|
|
|
core_info_t *info = NULL;
|
2020-06-18 16:08:57 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
if (!list || (i >= list->count))
|
|
|
|
return NULL;
|
|
|
|
info = (core_info_t*)&list->list[i];
|
|
|
|
if (!info || !info->path)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return info;
|
2020-06-18 16:08:57 +00:00
|
|
|
}
|
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
void core_info_list_get_supported_cores(core_info_list_t *core_info_list,
|
|
|
|
const char *path, const core_info_t **infos, size_t *num_infos)
|
2020-06-18 16:08:57 +00:00
|
|
|
{
|
2021-05-06 10:58:45 +00:00
|
|
|
size_t i;
|
|
|
|
size_t supported = 0;
|
|
|
|
#ifdef HAVE_COMPRESSION
|
|
|
|
struct string_list *list = NULL;
|
|
|
|
#endif
|
2021-09-20 13:43:27 +00:00
|
|
|
core_info_state_t *p_coreinfo = &core_info_st;
|
2020-06-18 16:08:57 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
if (!core_info_list)
|
|
|
|
return;
|
2020-08-27 10:10:14 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
p_coreinfo->tmp_path = path;
|
|
|
|
|
|
|
|
#ifdef HAVE_COMPRESSION
|
|
|
|
if (path_is_compressed_file(path))
|
2022-12-05 11:56:55 +00:00
|
|
|
list = file_archive_get_file_list(path, NULL);
|
|
|
|
p_coreinfo->tmp_list = list;
|
2020-08-28 15:27:48 +00:00
|
|
|
#endif
|
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
/* Let supported core come first in list so we can return
|
|
|
|
* a pointer to them. */
|
|
|
|
qsort(core_info_list->list, core_info_list->count,
|
|
|
|
sizeof(core_info_t), core_info_qsort_cmp);
|
2020-06-18 16:08:57 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
for (i = 0; i < core_info_list->count; i++, supported++)
|
2020-06-18 16:08:57 +00:00
|
|
|
{
|
2021-05-06 10:58:45 +00:00
|
|
|
const core_info_t *core = &core_info_list->list[i];
|
|
|
|
|
|
|
|
if (core_info_does_support_file(core, path))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
#ifdef HAVE_COMPRESSION
|
|
|
|
if (core_info_does_support_any_file(core, list))
|
|
|
|
continue;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
break;
|
2020-06-18 16:08:57 +00:00
|
|
|
}
|
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
#ifdef HAVE_COMPRESSION
|
|
|
|
if (list)
|
|
|
|
string_list_free(list);
|
|
|
|
#endif
|
2020-06-18 16:08:57 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
*infos = core_info_list->list;
|
|
|
|
*num_infos = supported;
|
|
|
|
}
|
2020-06-18 16:08:57 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
/*
|
|
|
|
* Matches core A and B file IDs
|
|
|
|
*
|
|
|
|
* e.g.:
|
|
|
|
* snes9x_libretro.dll and snes9x_libretro_android.so are matched
|
2024-06-16 17:42:32 +00:00
|
|
|
* snes9x__2005_libretro.dll and snes9x_libretro_android.so are
|
2021-05-06 10:58:45 +00:00
|
|
|
* NOT matched
|
|
|
|
*/
|
|
|
|
bool core_info_core_file_id_is_equal(const char *core_path_a,
|
|
|
|
const char *core_path_b)
|
|
|
|
{
|
|
|
|
char core_file_id_a[256];
|
|
|
|
char core_file_id_b[256];
|
2020-06-18 16:08:57 +00:00
|
|
|
|
2021-11-23 04:05:09 +00:00
|
|
|
if ( string_is_empty(core_path_a)
|
|
|
|
|| string_is_empty(core_path_b)
|
|
|
|
|| !core_info_get_file_id(
|
|
|
|
path_basename_nocompression(core_path_a),
|
|
|
|
core_file_id_a, sizeof(core_file_id_a))
|
|
|
|
|| !core_info_get_file_id(
|
|
|
|
path_basename_nocompression(core_path_b),
|
2021-05-06 10:58:45 +00:00
|
|
|
core_file_id_b, sizeof(core_file_id_b)))
|
|
|
|
return false;
|
2020-06-18 16:08:57 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
return string_is_equal(core_file_id_a, core_file_id_b);
|
2020-06-18 16:08:57 +00:00
|
|
|
}
|
2021-05-04 14:01:17 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
bool core_info_database_match_archive_member(const char *database_path)
|
2021-05-04 14:01:17 +00:00
|
|
|
{
|
2021-05-06 10:58:45 +00:00
|
|
|
char *database = NULL;
|
2021-11-23 04:05:09 +00:00
|
|
|
const char *new_path = path_basename_nocompression(
|
|
|
|
database_path);
|
2021-05-06 10:58:45 +00:00
|
|
|
core_info_state_t *p_coreinfo = NULL;
|
2021-05-04 14:01:17 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
if (string_is_empty(new_path))
|
|
|
|
return false;
|
|
|
|
if (!(database = strdup(new_path)))
|
|
|
|
return false;
|
2021-05-04 14:01:17 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
path_remove_extension(database);
|
|
|
|
|
2021-09-20 13:43:27 +00:00
|
|
|
p_coreinfo = &core_info_st;
|
2021-05-06 10:58:45 +00:00
|
|
|
|
|
|
|
if (p_coreinfo->curr_list)
|
2021-05-04 14:01:17 +00:00
|
|
|
{
|
2021-05-06 10:58:45 +00:00
|
|
|
size_t i;
|
2021-05-04 14:01:17 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
for (i = 0; i < p_coreinfo->curr_list->count; i++)
|
2021-05-04 14:01:17 +00:00
|
|
|
{
|
2021-05-06 10:58:45 +00:00
|
|
|
const core_info_t *info = &p_coreinfo->curr_list->list[i];
|
|
|
|
|
|
|
|
if (!info->database_match_archive_member)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (!string_list_find_elem(info->databases_list, database))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
free(database);
|
|
|
|
return true;
|
2021-05-04 14:01:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
free(database);
|
|
|
|
return false;
|
2021-05-04 14:01:17 +00:00
|
|
|
}
|
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
bool core_info_database_supports_content_path(
|
|
|
|
const char *database_path, const char *path)
|
2021-05-04 14:01:17 +00:00
|
|
|
{
|
2021-05-06 10:58:45 +00:00
|
|
|
char *database = NULL;
|
|
|
|
const char *new_path = path_basename(database_path);
|
|
|
|
core_info_state_t *p_coreinfo = NULL;
|
2021-05-04 14:01:17 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
if (string_is_empty(new_path))
|
|
|
|
return false;
|
|
|
|
if (!(database = strdup(new_path)))
|
|
|
|
return false;
|
2021-05-04 14:01:17 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
path_remove_extension(database);
|
2021-05-04 14:01:17 +00:00
|
|
|
|
2021-09-20 13:43:27 +00:00
|
|
|
p_coreinfo = &core_info_st;
|
2021-05-04 14:01:17 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
if (p_coreinfo->curr_list)
|
2021-05-04 14:01:17 +00:00
|
|
|
{
|
2021-05-06 10:58:45 +00:00
|
|
|
size_t i;
|
2021-05-04 14:01:17 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
for (i = 0; i < p_coreinfo->curr_list->count; i++)
|
2021-05-04 14:01:17 +00:00
|
|
|
{
|
2021-05-06 10:58:45 +00:00
|
|
|
const core_info_t *info = &p_coreinfo->curr_list->list[i];
|
|
|
|
|
|
|
|
if (!string_list_find_elem(info->supported_extensions_list,
|
|
|
|
path_get_extension(path)))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (!string_list_find_elem(info->databases_list, database))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
free(database);
|
|
|
|
return true;
|
2021-05-04 14:01:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
free(database);
|
|
|
|
return false;
|
2021-05-04 14:01:17 +00:00
|
|
|
}
|
|
|
|
|
2021-11-23 04:05:09 +00:00
|
|
|
bool core_info_list_get_display_name(
|
|
|
|
core_info_list_t *core_info_list,
|
2021-05-06 10:58:45 +00:00
|
|
|
const char *core_path, char *s, size_t len)
|
2021-05-04 14:01:17 +00:00
|
|
|
{
|
2022-03-04 12:43:00 +00:00
|
|
|
core_info_t *info;
|
|
|
|
|
|
|
|
if (!core_info_list)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
info = core_info_find_internal(
|
2021-05-06 10:58:45 +00:00
|
|
|
core_info_list, core_path);
|
2021-05-04 14:01:17 +00:00
|
|
|
|
2024-06-16 17:42:32 +00:00
|
|
|
if ( s
|
2022-12-05 11:56:55 +00:00
|
|
|
&& info
|
|
|
|
&& !string_is_empty(info->display_name))
|
2021-05-04 14:01:17 +00:00
|
|
|
{
|
2021-05-06 10:58:45 +00:00
|
|
|
strlcpy(s, info->display_name, len);
|
|
|
|
return true;
|
2021-05-04 14:01:17 +00:00
|
|
|
}
|
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
return false;
|
2021-05-04 14:01:17 +00:00
|
|
|
}
|
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
/* Returns core_info parameters required for
|
|
|
|
* core updater tasks, read from specified file.
|
|
|
|
* Returned core_updater_info_t object must be
|
|
|
|
* freed using core_info_free_core_updater_info().
|
|
|
|
* Returns NULL if 'path' is invalid. */
|
2021-11-23 04:05:09 +00:00
|
|
|
core_updater_info_t *core_info_get_core_updater_info(
|
|
|
|
const char *info_path)
|
2021-05-04 14:01:17 +00:00
|
|
|
{
|
2024-06-16 17:42:32 +00:00
|
|
|
struct config_entry_list
|
2021-05-06 10:58:45 +00:00
|
|
|
*entry = NULL;
|
|
|
|
bool tmp_bool = false;
|
|
|
|
core_updater_info_t *info = NULL;
|
|
|
|
config_file_t *conf = NULL;
|
2021-05-04 14:01:17 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
if (string_is_empty(info_path))
|
|
|
|
return NULL;
|
2021-05-04 14:01:17 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
/* Read config file */
|
2022-08-01 19:31:45 +00:00
|
|
|
if (!(conf = config_file_new_from_path_to_string(info_path)))
|
2021-05-06 10:58:45 +00:00
|
|
|
return NULL;
|
2021-05-04 14:01:17 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
/* Create info struct */
|
2022-08-01 19:31:45 +00:00
|
|
|
if (!(info = (core_updater_info_t*)malloc(sizeof(*info))))
|
2021-05-06 10:58:45 +00:00
|
|
|
return NULL;
|
2021-05-04 14:01:17 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
info->is_experimental = false;
|
|
|
|
info->display_name = NULL;
|
|
|
|
info->description = NULL;
|
|
|
|
info->licenses = NULL;
|
2021-05-04 14:01:17 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
/* Fetch required parameters */
|
2021-05-04 14:01:17 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
/* > is_experimental */
|
|
|
|
if (config_get_bool(conf, "is_experimental", &tmp_bool))
|
|
|
|
info->is_experimental = tmp_bool;
|
2021-05-04 14:01:17 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
/* > display_name */
|
|
|
|
entry = config_get_entry(conf, "display_name");
|
2021-05-04 14:01:17 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
if (entry && !string_is_empty(entry->value))
|
2021-05-04 14:01:17 +00:00
|
|
|
{
|
2021-05-06 10:58:45 +00:00
|
|
|
info->display_name = entry->value;
|
|
|
|
entry->value = NULL;
|
2021-05-04 14:01:17 +00:00
|
|
|
}
|
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
/* > description */
|
|
|
|
entry = config_get_entry(conf, "description");
|
2021-05-04 14:01:17 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
if (entry && !string_is_empty(entry->value))
|
|
|
|
{
|
|
|
|
info->description = entry->value;
|
|
|
|
entry->value = NULL;
|
|
|
|
}
|
2021-05-04 14:01:17 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
/* > licenses */
|
|
|
|
entry = config_get_entry(conf, "license");
|
2021-05-04 14:01:17 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
if (entry && !string_is_empty(entry->value))
|
2021-05-04 14:01:17 +00:00
|
|
|
{
|
2021-05-06 10:58:45 +00:00
|
|
|
info->licenses = entry->value;
|
|
|
|
entry->value = NULL;
|
2021-05-04 14:01:17 +00:00
|
|
|
}
|
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
/* Clean up */
|
|
|
|
config_file_free(conf);
|
2021-05-04 14:01:17 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
return info;
|
2021-05-04 14:01:17 +00:00
|
|
|
}
|
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
void core_info_free_core_updater_info(core_updater_info_t *info)
|
2021-05-04 14:01:17 +00:00
|
|
|
{
|
2021-05-06 10:58:45 +00:00
|
|
|
if (!info)
|
|
|
|
return;
|
2021-05-04 14:01:17 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
if (info->display_name)
|
|
|
|
free(info->display_name);
|
2021-05-04 14:01:17 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
if (info->description)
|
|
|
|
free(info->description);
|
2021-05-04 14:01:17 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
if (info->licenses)
|
|
|
|
free(info->licenses);
|
2021-05-04 14:01:17 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
free(info);
|
|
|
|
info = NULL;
|
|
|
|
}
|
2021-05-04 14:01:17 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
static int core_info_qsort_func_path(const core_info_t *a,
|
|
|
|
const core_info_t *b)
|
|
|
|
{
|
2022-08-01 19:31:45 +00:00
|
|
|
if (!a || !b || string_is_empty(a->path) || string_is_empty(b->path))
|
2021-05-06 10:58:45 +00:00
|
|
|
return 0;
|
|
|
|
return strcasecmp(a->path, b->path);
|
2021-05-04 14:01:17 +00:00
|
|
|
}
|
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
static int core_info_qsort_func_display_name(const core_info_t *a,
|
|
|
|
const core_info_t *b)
|
2021-05-04 14:01:17 +00:00
|
|
|
{
|
2022-08-01 19:31:45 +00:00
|
|
|
if ( !a
|
|
|
|
|| !b
|
2024-06-16 17:42:32 +00:00
|
|
|
|| string_is_empty(a->display_name)
|
2021-11-23 04:05:09 +00:00
|
|
|
|| string_is_empty(b->display_name))
|
2021-05-06 10:58:45 +00:00
|
|
|
return 0;
|
|
|
|
return strcasecmp(a->display_name, b->display_name);
|
|
|
|
}
|
2021-05-04 14:01:17 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
static int core_info_qsort_func_core_name(const core_info_t *a,
|
|
|
|
const core_info_t *b)
|
|
|
|
{
|
2022-08-01 19:31:45 +00:00
|
|
|
if ( !a
|
|
|
|
|| !b
|
2024-06-16 17:42:32 +00:00
|
|
|
|| string_is_empty(a->core_name)
|
2022-08-01 19:31:45 +00:00
|
|
|
|| string_is_empty(b->core_name))
|
2021-05-06 10:58:45 +00:00
|
|
|
return 0;
|
|
|
|
return strcasecmp(a->core_name, b->core_name);
|
2021-05-04 14:01:17 +00:00
|
|
|
}
|
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
static int core_info_qsort_func_system_name(const core_info_t *a,
|
|
|
|
const core_info_t *b)
|
2021-05-04 14:01:17 +00:00
|
|
|
{
|
2022-08-01 19:31:45 +00:00
|
|
|
if (
|
|
|
|
!a
|
|
|
|
|| !b
|
2024-06-16 17:42:32 +00:00
|
|
|
|| string_is_empty(a->systemname)
|
2022-08-01 19:31:45 +00:00
|
|
|
|| string_is_empty(b->systemname))
|
2021-05-06 10:58:45 +00:00
|
|
|
return 0;
|
|
|
|
return strcasecmp(a->systemname, b->systemname);
|
|
|
|
}
|
2021-05-04 14:01:17 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
void core_info_qsort(core_info_list_t *core_info_list,
|
|
|
|
enum core_info_list_qsort_type qsort_type)
|
|
|
|
{
|
|
|
|
if (!core_info_list)
|
|
|
|
return;
|
2021-05-04 14:01:17 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
if (core_info_list->count < 2)
|
2021-05-04 14:01:17 +00:00
|
|
|
return;
|
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
switch (qsort_type)
|
2021-05-04 14:01:17 +00:00
|
|
|
{
|
2021-05-06 10:58:45 +00:00
|
|
|
case CORE_INFO_LIST_SORT_PATH:
|
|
|
|
qsort(core_info_list->list,
|
|
|
|
core_info_list->count,
|
|
|
|
sizeof(core_info_t),
|
|
|
|
(int (*)(const void *, const void *))
|
|
|
|
core_info_qsort_func_path);
|
|
|
|
break;
|
|
|
|
case CORE_INFO_LIST_SORT_DISPLAY_NAME:
|
|
|
|
qsort(core_info_list->list,
|
|
|
|
core_info_list->count,
|
|
|
|
sizeof(core_info_t),
|
|
|
|
(int (*)(const void *, const void *))
|
|
|
|
core_info_qsort_func_display_name);
|
|
|
|
break;
|
|
|
|
case CORE_INFO_LIST_SORT_CORE_NAME:
|
|
|
|
qsort(core_info_list->list,
|
|
|
|
core_info_list->count,
|
|
|
|
sizeof(core_info_t),
|
|
|
|
(int (*)(const void *, const void *))
|
|
|
|
core_info_qsort_func_core_name);
|
|
|
|
break;
|
|
|
|
case CORE_INFO_LIST_SORT_SYSTEM_NAME:
|
|
|
|
qsort(core_info_list->list,
|
|
|
|
core_info_list->count,
|
|
|
|
sizeof(core_info_t),
|
|
|
|
(int (*)(const void *, const void *))
|
|
|
|
core_info_qsort_func_system_name);
|
|
|
|
break;
|
|
|
|
default:
|
2022-12-05 11:56:55 +00:00
|
|
|
break;
|
2021-05-04 14:01:17 +00:00
|
|
|
}
|
2021-05-06 10:58:45 +00:00
|
|
|
}
|
2021-05-04 14:01:17 +00:00
|
|
|
|
2022-02-02 15:49:53 +00:00
|
|
|
bool core_info_current_supports_savestate(void)
|
|
|
|
{
|
|
|
|
core_info_state_t *p_coreinfo = &core_info_st;
|
2023-01-26 14:56:33 +00:00
|
|
|
settings_t *settings = config_get_ptr();
|
|
|
|
|
|
|
|
if (settings->bools.core_info_savestate_bypass)
|
|
|
|
return true;
|
2022-02-02 15:49:53 +00:00
|
|
|
|
|
|
|
/* If no core is currently loaded, assume
|
|
|
|
* by default that all savestate functionality
|
|
|
|
* is supported */
|
|
|
|
if (!p_coreinfo->current)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
return p_coreinfo->current->savestate_support_level >=
|
|
|
|
CORE_INFO_SAVESTATE_BASIC;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool core_info_current_supports_rewind(void)
|
|
|
|
{
|
|
|
|
core_info_state_t *p_coreinfo = &core_info_st;
|
2023-01-26 14:56:33 +00:00
|
|
|
settings_t *settings = config_get_ptr();
|
|
|
|
|
|
|
|
if (settings->bools.core_info_savestate_bypass)
|
|
|
|
return true;
|
2022-02-02 15:49:53 +00:00
|
|
|
|
|
|
|
/* If no core is currently loaded, assume
|
|
|
|
* by default that all savestate functionality
|
|
|
|
* is supported */
|
|
|
|
if (!p_coreinfo->current)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
return p_coreinfo->current->savestate_support_level >=
|
|
|
|
CORE_INFO_SAVESTATE_SERIALIZED;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool core_info_current_supports_netplay(void)
|
|
|
|
{
|
|
|
|
core_info_state_t *p_coreinfo = &core_info_st;
|
2023-01-26 14:56:33 +00:00
|
|
|
settings_t *settings = config_get_ptr();
|
|
|
|
|
|
|
|
if (settings->bools.core_info_savestate_bypass)
|
|
|
|
return true;
|
2022-02-02 15:49:53 +00:00
|
|
|
|
|
|
|
/* If no core is currently loaded, assume
|
|
|
|
* by default that all savestate functionality
|
|
|
|
* is supported */
|
|
|
|
if (!p_coreinfo->current)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
return p_coreinfo->current->savestate_support_level >=
|
|
|
|
CORE_INFO_SAVESTATE_DETERMINISTIC;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool core_info_current_supports_runahead(void)
|
|
|
|
{
|
|
|
|
core_info_state_t *p_coreinfo = &core_info_st;
|
2023-01-26 14:56:33 +00:00
|
|
|
settings_t *settings = config_get_ptr();
|
|
|
|
|
|
|
|
if (settings->bools.core_info_savestate_bypass)
|
|
|
|
return true;
|
2022-02-02 15:49:53 +00:00
|
|
|
|
|
|
|
/* If no core is currently loaded, assume
|
|
|
|
* by default that all savestate functionality
|
|
|
|
* is supported */
|
|
|
|
if (!p_coreinfo->current)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
return p_coreinfo->current->savestate_support_level >=
|
|
|
|
CORE_INFO_SAVESTATE_DETERMINISTIC;
|
|
|
|
}
|
|
|
|
|
2022-03-09 16:49:16 +00:00
|
|
|
static bool core_info_update_core_aux_file(const char *path, bool create)
|
|
|
|
{
|
|
|
|
bool aux_file_exists = false;
|
|
|
|
|
|
|
|
if (string_is_empty(path))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
/* Check whether aux file exists */
|
|
|
|
aux_file_exists = path_is_valid(path);
|
|
|
|
|
|
|
|
/* Create or delete aux file, as required */
|
|
|
|
if (create && !aux_file_exists)
|
|
|
|
{
|
|
|
|
RFILE *aux_file = filestream_open(path,
|
|
|
|
RETRO_VFS_FILE_ACCESS_WRITE,
|
|
|
|
RETRO_VFS_FILE_ACCESS_HINT_NONE);
|
|
|
|
|
|
|
|
if (!aux_file)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
/* We have to write something - just output
|
|
|
|
* a single character */
|
|
|
|
if (filestream_putc(aux_file, 0) != 0)
|
|
|
|
{
|
|
|
|
filestream_close(aux_file);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
filestream_close(aux_file);
|
|
|
|
}
|
|
|
|
else if (!create && aux_file_exists)
|
|
|
|
if (filestream_delete(path) != 0)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
/* Sets 'locked' status of specified core
|
|
|
|
* > Returns true if successful
|
|
|
|
* > Like all functions that access the cached
|
|
|
|
* core info list this is *not* thread safe */
|
|
|
|
bool core_info_set_core_lock(const char *core_path, bool lock)
|
|
|
|
{
|
2023-06-20 14:33:55 +00:00
|
|
|
size_t _len;
|
2021-05-06 10:58:45 +00:00
|
|
|
core_info_t *core_info = NULL;
|
|
|
|
char lock_file_path[PATH_MAX_LENGTH];
|
2021-05-04 14:01:17 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
#if defined(ANDROID)
|
|
|
|
/* Play Store builds do not support
|
|
|
|
* core locking */
|
|
|
|
if (play_feature_delivery_enabled())
|
|
|
|
return false;
|
|
|
|
#endif
|
2021-05-04 14:01:17 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
/* Search for specified core */
|
2022-08-01 19:31:45 +00:00
|
|
|
if (
|
|
|
|
string_is_empty(core_path)
|
|
|
|
|| !core_info_find(core_path, &core_info)
|
|
|
|
|| string_is_empty(core_info->path))
|
2021-05-06 10:58:45 +00:00
|
|
|
return false;
|
2021-05-04 14:01:17 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
/* Get lock file path */
|
2023-06-20 14:33:55 +00:00
|
|
|
_len = strlcpy(lock_file_path, core_info->path,
|
|
|
|
sizeof(lock_file_path));
|
|
|
|
strlcpy(lock_file_path + _len,
|
|
|
|
".lck",
|
|
|
|
sizeof(lock_file_path) - _len);
|
2021-05-04 14:01:17 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
/* Create or delete lock file, as required */
|
2022-03-09 16:49:16 +00:00
|
|
|
if (!core_info_update_core_aux_file(lock_file_path, lock))
|
|
|
|
return false;
|
2021-05-04 14:01:17 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
/* File operations were successful - update
|
|
|
|
* core info entry */
|
|
|
|
core_info->is_locked = lock;
|
2021-05-04 14:01:17 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
return true;
|
2021-05-04 14:01:17 +00:00
|
|
|
}
|
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
/* Fetches 'locked' status of specified core
|
|
|
|
* > If 'validate_path' is 'true', will search
|
|
|
|
* cached core info list for a corresponding
|
|
|
|
* 'sanitised' core file path. This is *not*
|
|
|
|
* thread safe
|
|
|
|
* > If 'validate_path' is 'false', performs a
|
|
|
|
* direct filesystem check. This *is* thread
|
|
|
|
* safe, but validity of specified core path
|
|
|
|
* must be checked externally */
|
|
|
|
bool core_info_get_core_lock(const char *core_path, bool validate_path)
|
2021-05-04 14:01:17 +00:00
|
|
|
{
|
2023-06-20 14:33:55 +00:00
|
|
|
size_t _len;
|
2021-05-06 10:58:45 +00:00
|
|
|
core_info_t *core_info = NULL;
|
|
|
|
const char *core_file_path = NULL;
|
|
|
|
bool is_locked = false;
|
|
|
|
char lock_file_path[PATH_MAX_LENGTH];
|
2021-05-04 14:01:17 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
#if defined(ANDROID)
|
|
|
|
/* Play Store builds do not support
|
|
|
|
* core locking */
|
|
|
|
if (play_feature_delivery_enabled())
|
|
|
|
return false;
|
|
|
|
#endif
|
2021-05-04 14:01:17 +00:00
|
|
|
|
2021-05-06 10:58:45 +00:00
|
|
|
if (string_is_empty(core_path))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
/* Check whether core path is to be validated */
|
|
|
|
if (validate_path)
|
|
|
|
{
|
|
|
|
if (core_info_find(core_path, &core_info))
|
|
|
|
core_file_path = core_info->path;
|
2021-05-04 14:01:17 +00:00
|
|
|
}
|
2021-05-06 10:58:45 +00:00
|
|
|
else
|
2022-12-05 11:56:55 +00:00
|
|
|
core_file_path = core_path;
|
2021-05-06 10:58:45 +00:00
|
|
|
|
|
|
|
/* A core cannot be locked if it does not exist... */
|
2022-12-05 11:56:55 +00:00
|
|
|
if ( string_is_empty(core_file_path)
|
|
|
|
|| !path_is_valid(core_file_path))
|
2021-05-06 10:58:45 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
/* Get lock file path */
|
2023-06-20 14:33:55 +00:00
|
|
|
_len = strlcpy(lock_file_path, core_file_path,
|
2022-07-22 20:23:54 +00:00
|
|
|
sizeof(lock_file_path));
|
2023-06-20 14:33:55 +00:00
|
|
|
strlcpy(lock_file_path + _len,
|
|
|
|
".lck",
|
|
|
|
sizeof(lock_file_path) - _len);
|
2021-05-06 10:58:45 +00:00
|
|
|
|
|
|
|
/* Check whether lock file exists */
|
|
|
|
is_locked = path_is_valid(lock_file_path);
|
|
|
|
|
|
|
|
/* If core path has been validated (and a
|
|
|
|
* core info object is available), ensure
|
|
|
|
* that core info 'is_locked' field is
|
|
|
|
* up to date */
|
|
|
|
if (validate_path && core_info)
|
|
|
|
core_info->is_locked = is_locked;
|
|
|
|
|
|
|
|
return is_locked;
|
2021-05-04 14:01:17 +00:00
|
|
|
}
|
2022-03-09 16:49:16 +00:00
|
|
|
|
|
|
|
/* Sets 'standalone exempt' status of specified core
|
|
|
|
* > A 'standalone exempt' core will not be shown
|
|
|
|
* in the contentless cores menu when display type
|
|
|
|
* is set to 'custom'
|
|
|
|
* > Returns true if successful
|
|
|
|
* > Returns false if core does not support
|
|
|
|
* contentless operation
|
|
|
|
* > *Not* thread safe */
|
|
|
|
bool core_info_set_core_standalone_exempt(const char *core_path, bool exempt)
|
|
|
|
{
|
2022-12-05 11:56:55 +00:00
|
|
|
/* Static platforms do not support the contentless
|
|
|
|
* cores menu */
|
2022-03-09 16:49:16 +00:00
|
|
|
#if defined(HAVE_DYNAMIC)
|
2022-08-08 20:41:32 +00:00
|
|
|
size_t _len;
|
2022-03-09 16:49:16 +00:00
|
|
|
core_info_t *core_info = NULL;
|
|
|
|
char exempt_file_path[PATH_MAX_LENGTH];
|
|
|
|
|
|
|
|
/* Search for specified core */
|
2022-08-01 19:31:45 +00:00
|
|
|
if ( string_is_empty(core_path)
|
|
|
|
|| !core_info_find(core_path, &core_info)
|
|
|
|
|| string_is_empty(core_info->path)
|
|
|
|
|| !core_info->supports_no_game)
|
2022-03-09 16:49:16 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
/* Get 'standalone exempt' file path */
|
2023-06-20 14:33:55 +00:00
|
|
|
_len = strlcpy(exempt_file_path, core_info->path,
|
2022-07-22 20:23:54 +00:00
|
|
|
sizeof(exempt_file_path));
|
2023-06-20 14:33:55 +00:00
|
|
|
strlcpy(exempt_file_path + _len,
|
|
|
|
".lsae",
|
|
|
|
sizeof(exempt_file_path) - _len);
|
2022-03-09 16:49:16 +00:00
|
|
|
|
|
|
|
/* Create or delete 'standalone exempt' file, as required */
|
2022-12-05 11:56:55 +00:00
|
|
|
if (core_info_update_core_aux_file(exempt_file_path, exempt))
|
|
|
|
{
|
|
|
|
/* File operations were successful - update
|
|
|
|
* core info entry */
|
|
|
|
core_info->is_standalone_exempt = exempt;
|
|
|
|
return true;
|
|
|
|
}
|
2022-03-09 16:49:16 +00:00
|
|
|
#endif
|
2022-12-05 11:56:55 +00:00
|
|
|
return false;
|
2022-03-09 16:49:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Fetches 'standalone exempt' status of specified core
|
|
|
|
* > Returns true if core should be excluded from
|
|
|
|
* the contentless cores menu when display type is
|
|
|
|
* set to 'custom'
|
|
|
|
* > *Not* thread safe */
|
|
|
|
bool core_info_get_core_standalone_exempt(const char *core_path)
|
|
|
|
{
|
2022-12-05 11:56:55 +00:00
|
|
|
/* Static platforms do not support the contentless
|
|
|
|
* cores menu */
|
2022-03-09 16:49:16 +00:00
|
|
|
#if defined(HAVE_DYNAMIC)
|
2022-08-08 20:41:32 +00:00
|
|
|
size_t _len;
|
2022-03-09 16:49:16 +00:00
|
|
|
core_info_t *core_info = NULL;
|
|
|
|
char exempt_file_path[PATH_MAX_LENGTH];
|
|
|
|
|
|
|
|
/* Search for specified core */
|
2022-08-01 19:31:45 +00:00
|
|
|
if ( string_is_empty(core_path)
|
|
|
|
|| !core_info_find(core_path, &core_info)
|
|
|
|
|| string_is_empty(core_info->path)
|
|
|
|
|| !core_info->supports_no_game)
|
2022-03-09 16:49:16 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
/* Get 'standalone exempt' file path */
|
2023-06-20 14:33:55 +00:00
|
|
|
_len = strlcpy(exempt_file_path, core_info->path,
|
2022-07-22 20:23:54 +00:00
|
|
|
sizeof(exempt_file_path));
|
2023-06-20 14:33:55 +00:00
|
|
|
strlcpy(exempt_file_path + _len,
|
|
|
|
".lsae",
|
|
|
|
sizeof(exempt_file_path) - _len);
|
2022-03-09 16:49:16 +00:00
|
|
|
|
|
|
|
/* Check whether 'standalone exempt' file exists */
|
2022-12-05 11:56:55 +00:00
|
|
|
if (path_is_valid(exempt_file_path))
|
|
|
|
{
|
|
|
|
core_info->is_standalone_exempt = true;
|
|
|
|
return true;
|
|
|
|
}
|
2022-03-09 16:49:16 +00:00
|
|
|
|
2022-12-05 11:56:55 +00:00
|
|
|
core_info->is_standalone_exempt = false;
|
2022-03-09 16:49:16 +00:00
|
|
|
#endif
|
2022-12-05 11:56:55 +00:00
|
|
|
return false;
|
2022-03-09 16:49:16 +00:00
|
|
|
}
|