diff --git a/apple/common/RetroArch_Apple.h b/apple/common/RetroArch_Apple.h index 102143cd2d..9e86654da8 100644 --- a/apple/common/RetroArch_Apple.h +++ b/apple/common/RetroArch_Apple.h @@ -21,7 +21,6 @@ #import #include "../../frontend/info/core_info.h" -#include "core_info_ext.h" #include "setting_data.h" #include "apple_export.h" diff --git a/apple/common/core_info_ext.c b/apple/common/core_info_ext.c deleted file mode 100644 index 62db5296d5..0000000000 --- a/apple/common/core_info_ext.c +++ /dev/null @@ -1,121 +0,0 @@ -/* RetroArch - A frontend for libretro. - * Copyright (C) 2013-2014 - Jason Fetters - * - * 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 . - */ - -#include "core_info_ext.h" - -static core_info_list_t* global_core_list = 0; -static char core_config_path[PATH_MAX]; - -void apple_core_info_set_core_path(const char* core_path) -{ - if (global_core_list) - core_info_list_free(global_core_list); - - global_core_list = core_path ? core_info_list_new(core_path) : 0; - - if (!global_core_list) - RARCH_WARN("No cores were found at %s", core_path ? core_path : "(null"); -} - -void apple_core_info_set_config_path(const char* config_path) -{ - if (!config_path || strlcpy(core_config_path, config_path, sizeof(core_config_path)) >= PATH_MAX) - *core_config_path = '\0'; -} - -core_info_list_t *apple_core_info_list_get(void) -{ - if (!global_core_list) - RARCH_WARN("core_info_list_get() called before core_info_set_core_path()"); - - return global_core_list; -} - -const core_info_t *apple_core_info_list_get_by_id(const char* core_id) -{ - if (core_id) - { - const core_info_list_t* cores = apple_core_info_list_get(); - - for (int i = 0; i != cores->count; i ++) - if (cores->list[i].path && strcmp(core_id, cores->list[i].path) == 0) - return &cores->list[i]; - } - - return 0; -} - -const char *apple_core_info_get_id(const core_info_t* info, char* buffer, size_t buffer_length) -{ - if (!buffer || !buffer_length) - return ""; - - if (info && info->path && strlcpy(buffer, info->path, buffer_length) < buffer_length) - return buffer; - - *buffer = 0; - return buffer; -} - -const char *apple_core_info_get_custom_config(const char* core_id, char* buffer, size_t buffer_length) -{ - if (!core_id || !buffer || !buffer_length) - return 0; - - snprintf(buffer, buffer_length, "%s/%s", core_config_path, path_basename(core_id)); - fill_pathname(buffer, buffer, ".cfg", buffer_length); - return buffer; -} - -bool apple_core_info_has_custom_config(const char* core_id) -{ - char path[PATH_MAX]; - if (!core_id) - return false; - - apple_core_info_get_custom_config(core_id, path, sizeof(path)); - return path_file_exists(path); -} - -// ROM HISTORY EXTENSIONS -const char* apple_rom_history_get_path(rom_history_t* history, uint32_t index) -{ - const char *path, *core_path, *core_name; - rom_history_get_index(history, index, &path, &core_path, &core_name); - - if (path) - return path; - return ""; -} - -const char *apple_rom_history_get_core_path(rom_history_t* history, uint32_t index) -{ - const char *path, *core_path, *core_name; - rom_history_get_index(history, index, &path, &core_path, &core_name); - - if (core_path) - return core_path; - return ""; -} - -const char *apple_rom_history_get_core_name(rom_history_t* history, uint32_t index) -{ - const char *path, *core_path, *core_name; - rom_history_get_index(history, index, &path, &core_path, &core_name); - - if (core_name) - return core_name; - return ""; -} diff --git a/apple/common/core_info_ext.h b/apple/common/core_info_ext.h deleted file mode 100644 index abb8ed1266..0000000000 --- a/apple/common/core_info_ext.h +++ /dev/null @@ -1,38 +0,0 @@ -/* RetroArch - A frontend for libretro. - * Copyright (C) 2013-2014 - Jason Fetters - * - * 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 . - */ - -#ifndef __APPLE_RARCH_CORE_INFO_EXT_H__ -#define __APPLE_RARCH_CORE_INFO_EXT_H__ - -#include "../../frontend/info/core_info.h" -#include "../../frontend/menu/history.h" - -void apple_core_info_set_core_path(const char* core_path); -void apple_core_info_set_config_path(const char* config_path); - -core_info_list_t* apple_core_info_list_get(void); -const core_info_t* apple_core_info_list_get_by_id(const char* core_id); -const char* apple_core_info_get_id(const core_info_t* info, char* buffer, size_t buffer_length); - -const char* apple_core_info_get_custom_config(const char* core_id, char* buffer, size_t buffer_length); -bool apple_core_info_has_custom_config(const char* core_id); - - -// ROM HISTORY EXTENSIONS -const char* apple_rom_history_get_path(rom_history_t* history, uint32_t index); -const char* apple_rom_history_get_core_path(rom_history_t* history, uint32_t index); -const char* apple_rom_history_get_core_name(rom_history_t* history, uint32_t index); - -#endif diff --git a/frontend/info/core_info.c b/frontend/info/core_info.c index 5458c11d93..9e9d2b23f6 100644 --- a/frontend/info/core_info.c +++ b/frontend/info/core_info.c @@ -24,6 +24,9 @@ #include "../../config.h" #endif +static core_info_list_t* global_core_list = 0; +static char core_config_path[PATH_MAX]; + static void core_info_list_resolve_all_extensions(core_info_list_t *core_info_list) { size_t i, all_ext_len = 0; @@ -402,3 +405,73 @@ void core_info_list_get_missing_firmware(core_info_list_t *core_info_list, qsort(info->firmware, info->firmware_count, sizeof(*info->firmware), core_info_firmware_cmp); } + +void core_info_set_core_path(const char* core_path) +{ + if (global_core_list) + core_info_list_free(global_core_list); + + global_core_list = core_path ? core_info_list_new(core_path) : 0; + + if (!global_core_list) + RARCH_WARN("No cores were found at %s", core_path ? core_path : "(null"); +} + +void core_info_set_config_path(const char* config_path) +{ + if (!config_path || strlcpy(core_config_path, config_path, sizeof(core_config_path)) >= PATH_MAX) + *core_config_path = '\0'; +} + +core_info_list_t *core_info_list_get(void) +{ + if (!global_core_list) + RARCH_WARN("core_info_list_get() called before core_info_set_core_path()"); + + return global_core_list; +} + +const core_info_t *core_info_list_get_by_id(const char* core_id) +{ + int i; + const core_info_list_t* cores = (const core_info_list_t*)core_info_list_get(); + + if (core_id) + for (i = 0; i < cores->count; i ++) + if (cores->list[i].path && strcmp(core_id, cores->list[i].path) == 0) + return &cores->list[i]; + + return 0; +} + +const char *core_info_get_id(const core_info_t* info, char* buffer, size_t buffer_length) +{ + if (!buffer || !buffer_length) + return ""; + + if (info && info->path && strlcpy(buffer, info->path, buffer_length) < buffer_length) + return buffer; + + *buffer = 0; + return buffer; +} + +const char *core_info_get_custom_config(const char* core_id, char* buffer, size_t buffer_length) +{ + if (!core_id || !buffer || !buffer_length) + return 0; + + snprintf(buffer, buffer_length, "%s/%s", core_config_path, path_basename(core_id)); + fill_pathname(buffer, buffer, ".cfg", buffer_length); + return buffer; +} + +bool core_info_has_custom_config(const char* core_id) +{ + char path[PATH_MAX]; + if (!core_id) + return false; + + core_info_get_custom_config(core_id, path, sizeof(path)); + return path_file_exists(path); +} diff --git a/frontend/info/core_info.h b/frontend/info/core_info.h index 1852bfb35b..ad9b4ad66e 100644 --- a/frontend/info/core_info.h +++ b/frontend/info/core_info.h @@ -1,5 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen + * Copyright (C) 2011-2014 - Daniel De Matteis + * Copyright (C) 2013-2014 - Jason Fetters * * 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- @@ -84,6 +86,16 @@ const char *core_info_list_get_all_extensions(core_info_list_t *core_info_list); bool core_info_list_get_display_name(core_info_list_t *core_info_list, const char *path, char *buf, size_t size); +void core_info_set_core_path(const char* core_path); +void core_info_set_config_path(const char* config_path); + +core_info_list_t* core_info_list_get(void); +const core_info_t* core_info_list_get_by_id(const char* core_id); +const char* core_info_get_id(const core_info_t* info, char* buffer, size_t buffer_length); + +const char* core_info_get_custom_config(const char* core_id, char* buffer, size_t buffer_length); +bool core_info_has_custom_config(const char* core_id); + #ifdef __cplusplus } #endif diff --git a/frontend/menu/history.c b/frontend/menu/history.c index 8df6a2e833..63878fad43 100644 --- a/frontend/menu/history.c +++ b/frontend/menu/history.c @@ -1,5 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen + * Copyright (C) 2011-2014 - Daniel De Matteis + * Copyright (C) 2013-2014 - Jason Fetters * * 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- @@ -211,3 +213,32 @@ error: return NULL; } +const char* rom_history_get_path(rom_history_t* history, unsigned index) +{ + const char *path, *core_path, *core_name; + rom_history_get_index(history, index, &path, &core_path, &core_name); + + if (path) + return path; + return ""; +} + +const char *rom_history_get_core_path(rom_history_t* history, unsigned index) +{ + const char *path, *core_path, *core_name; + rom_history_get_index(history, index, &path, &core_path, &core_name); + + if (core_path) + return core_path; + return ""; +} + +const char *rom_history_get_core_name(rom_history_t* history, unsigned index) +{ + const char *path, *core_path, *core_name; + rom_history_get_index(history, index, &path, &core_path, &core_name); + + if (core_name) + return core_name; + return ""; +} diff --git a/frontend/menu/history.h b/frontend/menu/history.h index 67806bddb9..a818a4a98d 100644 --- a/frontend/menu/history.h +++ b/frontend/menu/history.h @@ -40,6 +40,13 @@ void rom_history_push(rom_history_t *hist, const char *path, const char *core_path, const char *core_name); +const char* rom_history_get_path(rom_history_t* history, + unsigned index); +const char* rom_history_get_core_path(rom_history_t* history, + unsigned index); +const char* rom_history_get_core_name(rom_history_t* history, + unsigned index); + #ifdef __cplusplus } #endif diff --git a/griffin/griffin.c b/griffin/griffin.c index 9034522593..de83358591 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -660,7 +660,6 @@ XML #if defined(IOS) || defined(OSX) #include "../apple/common/setting_data.c" -#include "../apple/common/core_info_ext.c" #endif #ifdef __cplusplus