RetroArch/system.c

89 lines
2.6 KiB
C
Raw Normal View History

2015-06-25 12:25:21 +00:00
/* RetroArch - A frontend for libretro.
* Copyright (C) 2011-2015 - Daniel De Matteis
*
* 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/>.
*/
2015-06-25 12:30:32 +00:00
#include <compat/strl.h>
2015-06-25 12:25:21 +00:00
#include "system.h"
2015-06-25 12:30:32 +00:00
#include "dynamic.h"
2015-07-02 03:33:21 +00:00
#include "msg_hash.h"
2015-06-25 12:30:32 +00:00
#ifdef HAVE_ZLIB
#define DEFAULT_EXT "zip"
#else
#define DEFAULT_EXT ""
#endif
2015-06-25 12:25:21 +00:00
static rarch_system_info_t *g_system;
static rarch_system_info_t *rarch_system_info_new(void)
{
return (rarch_system_info_t*)calloc(1, sizeof(rarch_system_info_t));
}
rarch_system_info_t *rarch_system_info_get_ptr(void)
{
if (!g_system)
g_system = rarch_system_info_new();
return g_system;
}
void rarch_system_info_free(void)
{
if (!g_system)
return;
if (g_system->core_options)
{
core_option_flush(g_system->core_options);
core_option_free(g_system->core_options);
}
/* No longer valid. */
if (g_system->special)
free(g_system->special);
g_system->special = NULL;
if (g_system->ports)
free(g_system->ports);
g_system->ports = NULL;
free(g_system);
g_system = NULL;
}
2015-06-25 12:30:32 +00:00
void rarch_system_info_init(void)
{
rarch_system_info_t *system = rarch_system_info_get_ptr();
core.retro_get_system_info(&system->info);
2015-06-25 12:30:32 +00:00
if (!system->info.library_name)
2015-07-02 03:33:21 +00:00
system->info.library_name = msg_hash_to_str(MSG_UNKNOWN);
2015-06-25 12:30:32 +00:00
if (!system->info.library_version)
system->info.library_version = "v0";
#ifndef RARCH_CONSOLE
2015-07-02 22:16:46 +00:00
strlcpy(system->title_buf,
msg_hash_to_str(MSG_PROGRAM), sizeof(system->title_buf));
strlcat(system->title_buf, " : ", sizeof(system->title_buf));
2015-06-25 12:30:32 +00:00
#endif
strlcat(system->title_buf, system->info.library_name, sizeof(system->title_buf));
strlcat(system->title_buf, " ", sizeof(system->title_buf));
strlcat(system->title_buf, system->info.library_version, sizeof(system->title_buf));
strlcpy(system->valid_extensions, system->info.valid_extensions ?
system->info.valid_extensions : DEFAULT_EXT,
sizeof(system->valid_extensions));
system->block_extract = system->info.block_extract;
}