mirror of
https://github.com/CTCaer/RetroArch.git
synced 2024-12-13 13:28:49 +00:00
Move code to database_info.c
This commit is contained in:
parent
32412ab918
commit
2f0b2460e7
@ -339,7 +339,6 @@ ifeq ($(HAVE_MENU_COMMON), 1)
|
||||
menu/menu_entry.o \
|
||||
menu/menu_navigation.o \
|
||||
menu/menu_setting.o \
|
||||
menu/menu_database.o \
|
||||
menu/menu_shader.o \
|
||||
menu/menu_entries_cbs_ok.o \
|
||||
menu/menu_entries_cbs_cancel.o \
|
||||
|
@ -381,3 +381,23 @@ void database_info_list_free(database_info_list_t *database_info_list)
|
||||
free(database_info_list->list);
|
||||
free(database_info_list);
|
||||
}
|
||||
|
||||
void database_playlist_free(content_playlist_t *db_playlist)
|
||||
{
|
||||
if (db_playlist)
|
||||
content_playlist_free(db_playlist);
|
||||
}
|
||||
|
||||
bool database_playlist_realloc(
|
||||
content_playlist_t *db_playlist,
|
||||
const char *path)
|
||||
{
|
||||
database_playlist_free(db_playlist);
|
||||
|
||||
db_playlist = content_playlist_init(path, 1000);
|
||||
|
||||
if (!db_playlist)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include <stddef.h>
|
||||
#include <boolean.h>
|
||||
#include "libretro-db/libretrodb.h"
|
||||
#include "playlist.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -107,6 +108,11 @@ void database_info_free(database_info_handle_t *dbl);
|
||||
int database_info_build_query(
|
||||
char *query, size_t len, const char *label, const char *path);
|
||||
|
||||
void database_playlist_free(content_playlist_t *db_playlist);
|
||||
|
||||
bool database_playlist_realloc(
|
||||
content_playlist_t *db_playlist, const char *path);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -734,7 +734,6 @@ MENU
|
||||
#include "../menu/menu_display.c"
|
||||
#include "../menu/menu_displaylist.c"
|
||||
#include "../menu/menu_animation.c"
|
||||
#include "../menu/menu_database.c"
|
||||
|
||||
#include "../menu/drivers/null.c"
|
||||
#endif
|
||||
|
@ -230,7 +230,7 @@ void menu_free(menu_handle_t *menu)
|
||||
menu_driver_free(menu);
|
||||
|
||||
#ifdef HAVE_LIBRETRODB
|
||||
menu_database_free(menu);
|
||||
database_playlist_free(menu->db_playlist);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_DYNAMIC
|
||||
|
@ -1,59 +0,0 @@
|
||||
/* 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/>.
|
||||
*/
|
||||
|
||||
#include "menu.h"
|
||||
#include "menu_database.h"
|
||||
#include "menu_list.h"
|
||||
#include "../playlist.h"
|
||||
#include <string.h>
|
||||
|
||||
static void menu_database_playlist_free(menu_handle_t *menu)
|
||||
{
|
||||
if (menu->db_playlist)
|
||||
content_playlist_free(menu->db_playlist);
|
||||
menu->db_playlist = NULL;
|
||||
}
|
||||
|
||||
void menu_database_free(void *data)
|
||||
{
|
||||
menu_handle_t *menu = (menu_handle_t*)data;
|
||||
if (!menu)
|
||||
return;
|
||||
menu_database_playlist_free(menu);
|
||||
}
|
||||
|
||||
bool menu_database_realloc(const char *path,
|
||||
bool force)
|
||||
{
|
||||
menu_handle_t *menu = menu_driver_get_ptr();
|
||||
if (!menu)
|
||||
return false;
|
||||
|
||||
if (!strcmp(menu->db_playlist_file, path) && !force)
|
||||
return true;
|
||||
|
||||
menu_database_playlist_free(menu);
|
||||
|
||||
menu->db_playlist = content_playlist_init(path,
|
||||
1000);
|
||||
|
||||
if (!menu->db_playlist)
|
||||
return false;
|
||||
|
||||
strlcpy(menu->db_playlist_file, path,
|
||||
sizeof(menu->db_playlist_file));
|
||||
|
||||
return true;
|
||||
}
|
@ -31,11 +31,6 @@ extern "C" {
|
||||
/* HACK */
|
||||
extern unsigned int rdb_entry_start_game_selection_ptr;
|
||||
|
||||
void menu_database_free(void *data);
|
||||
|
||||
bool menu_database_realloc(const char *path,
|
||||
bool force);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -900,6 +900,7 @@ static int create_string_list_rdb_entry_int(const char *desc, const char *label,
|
||||
static int menu_displaylist_parse_database_entry(menu_displaylist_info_t *info)
|
||||
{
|
||||
#ifdef HAVE_LIBRETRODB
|
||||
bool reallocate_playlist = false;
|
||||
char query[PATH_MAX_LENGTH];
|
||||
content_playlist_t *playlist;
|
||||
database_info_list_t *db_info = NULL;
|
||||
@ -922,7 +923,14 @@ static int menu_displaylist_parse_database_entry(menu_displaylist_info_t *info)
|
||||
fill_pathname_join(path_playlist, settings->playlist_directory, path_base,
|
||||
sizeof(path_playlist));
|
||||
|
||||
menu_database_realloc(path_playlist, false);
|
||||
reallocate_playlist = !(!strcmp(menu->db_playlist_file, path_playlist));
|
||||
|
||||
if (reallocate_playlist)
|
||||
{
|
||||
if (database_playlist_realloc(menu->db_playlist, path_playlist))
|
||||
strlcpy(menu->db_playlist_file, path_playlist,
|
||||
sizeof(menu->db_playlist_file));
|
||||
}
|
||||
|
||||
playlist = menu->db_playlist;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user