Rename history.c to playlist.c

This commit is contained in:
twinaphex 2014-08-15 17:24:28 +02:00
parent fda5e310f2
commit eb1d78bab7
14 changed files with 62 additions and 64 deletions

View File

@ -117,7 +117,7 @@ ifeq ($(HAVE_LAKKA), 1)
endif
endif
OBJ += history.o
OBJ += playlist.o
ifeq ($(HAVE_MENU_COMMON), 1)
OBJ += frontend/menu/backend/menu_common_backend.o frontend/menu/menu_input_line_cb.o frontend/menu/menu_common.o frontend/menu/menu_navigation.o

View File

@ -86,7 +86,7 @@ ifeq ($(HAVE_RGUI), 1)
HAVE_MENU_COMMON = 1
endif
OBJ += history.o
OBJ += playlist.o
ifeq ($(HAVE_MENU_COMMON), 1)
OBJ += frontend/menu/backend/menu_common_backend.o frontend/menu/menu_input_line_cb.o frontend/menu/menu_common.o frontend/menu/menu_navigation.o

View File

@ -131,7 +131,7 @@ ifeq ($(HAVE_LAKKA), 1)
endif
endif
OBJ += history.o
OBJ += playlist.o
ifeq ($(HAVE_MENU_COMMON), 1)
OBJ += frontend/menu/backend/menu_common_backend.o frontend/menu/menu_input_line_cb.o frontend/menu/menu_common.o frontend/menu/menu_navigation.o

View File

@ -522,7 +522,7 @@ bool rarch_environment_cb(unsigned cmd, void *data)
char buf[PATH_MAX];
if (!*options_path && *g_extern.config_path)
{
fill_pathname_resolve_relative(buf, g_extern.config_path, ".retroarch-core-options.cfg", sizeof(buf));
fill_pathname_resolve_relative(buf, g_extern.config_path, "retroarch-core-options.cfg", sizeof(buf));
options_path = buf;
}
g_extern.system.core_options = core_option_new(options_path, vars);

View File

@ -1752,14 +1752,14 @@ static void menu_parse_and_resolve(unsigned menu_type)
{
case MENU_SETTINGS_OPEN_HISTORY:
/* History parse */
list_size = content_history_size(g_extern.history);
list_size = content_playlist_size(g_extern.history);
for (i = 0; i < list_size; i++)
{
char fill_buf[PATH_MAX];
const char *path, *core_path, *core_name = NULL;
content_history_get_index(g_extern.history, i,
content_playlist_get_index(g_extern.history, i,
&path, &core_path, &core_name);
if (path)

View File

@ -93,7 +93,7 @@ void menu_content_history_push_current(void)
if (g_extern.system.no_content || *tmp)
if (g_extern.history)
content_history_push(g_extern.history,
content_playlist_push(g_extern.history,
*tmp ? tmp : NULL,
g_settings.libretro,
g_extern.system.info.library_name);
@ -116,7 +116,7 @@ static void load_menu_content_prepare(void)
msg_queue_push(g_extern.msg_queue, str, 1, 1);
}
content_history_push(g_extern.history,
content_playlist_push(g_extern.history,
*g_extern.fullpath ? g_extern.fullpath : NULL,
g_settings.libretro,
driver.menu->info.library_name ? driver.menu->info.library_name : "");
@ -149,7 +149,7 @@ void load_menu_content_history(unsigned game_index)
if (!driver.menu)
return;
content_history_get_index(g_extern.history,
content_playlist_get_index(g_extern.history,
game_index, &path, &core_path, &core_name);
strlcpy(g_settings.libretro, core_path, sizeof(g_settings.libretro));

View File

@ -27,7 +27,7 @@
#include "menu_navigation.h"
#include "../../core_info.h"
#include "../../file_list.h"
#include "../../history.h"
#include "../../playlist.h"
#include "../../input/input_common.h"
#include "../../input/keyboard_line.h"
#include "../../performance.h"

View File

@ -35,7 +35,7 @@
#include "miscellaneous.h"
#include "gfx/filter.h"
#include "history.h"
#include "playlist.h"
#ifdef HAVE_CONFIG_H
#include "config.h"
@ -404,7 +404,7 @@ struct global
struct string_list *temporary_content;
content_history_t *history;
content_playlist_t *history;
uint32_t content_crc;

View File

@ -595,9 +595,9 @@ SCREENSHOTS
/*============================================================
HISTORY
PLAYLISTS
============================================================ */
#include "../history.c"
#include "../playlist.c"
/*============================================================
MENU

View File

@ -217,7 +217,7 @@
<ClCompile Include="..\..\deps\rzlib\unzip.c" />
<ClCompile Include="..\..\deps\rzlib\zutil.c" />
<ClCompile Include="..\..\file_extract.c" />
<ClCompile Include="..\..\history.c" />
<ClCompile Include="..\..\playlist.c" />
<ClCompile Include="..\..\file_list.c" />
<ClCompile Include="..\..\frontend\menu\backend\menu_common_backend.c" />
<ClCompile Include="..\..\frontend\menu\disp\rgui.c" />

View File

@ -5,8 +5,6 @@
<ClCompile Include="..\..\cheats.c" />
<ClCompile Include="..\..\core_options.c" />
<ClCompile Include="..\..\file_extract.c" />
<ClCompile Include="..\..\frontend\menu\history.c" />
<ClCompile Include="..\..\frontend\menu\file_list.c" />
<ClCompile Include="..\..\performance.c" />
<ClCompile Include="..\..\command.c" />
<ClCompile Include="..\..\conf\config_file.c" />

View File

@ -15,7 +15,7 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#include "history.h"
#include "playlist.h"
#include "msvc/msvc_compat.h"
#include "compat/posix_string.h"
#include "boolean.h"
@ -26,23 +26,23 @@
#include <stdlib.h>
#include <string.h>
struct content_history_entry
struct content_playlist_entry
{
char *path;
char *core_path;
char *core_name;
};
struct content_history
struct content_playlist
{
struct content_history_entry *entries;
struct content_playlist_entry *entries;
size_t size;
size_t cap;
char *conf_path;
};
void content_history_get_index(content_history_t *hist,
void content_playlist_get_index(content_playlist_t *hist,
size_t index,
const char **path, const char **core_path,
const char **core_name)
@ -55,7 +55,7 @@ void content_history_get_index(content_history_t *hist,
*core_name = hist->entries[index].core_name;
}
static void content_history_free_entry(struct content_history_entry *entry)
static void content_playlist_free_entry(struct content_playlist_entry *entry)
{
if (entry->path)
free(entry->path);
@ -70,7 +70,7 @@ static void content_history_free_entry(struct content_history_entry *entry)
memset(entry, 0, sizeof(*entry));
}
void content_history_push(content_history_t *hist,
void content_playlist_push(content_playlist_t *hist,
const char *path, const char *core_path,
const char *core_name)
{
@ -92,9 +92,9 @@ void content_history_push(content_history_t *hist,
return;
// Seen it before, bump to top.
struct content_history_entry tmp = hist->entries[i];
struct content_playlist_entry tmp = hist->entries[i];
memmove(hist->entries + 1, hist->entries,
i * sizeof(struct content_history_entry));
i * sizeof(struct content_playlist_entry));
hist->entries[0] = tmp;
return;
}
@ -102,12 +102,12 @@ void content_history_push(content_history_t *hist,
if (hist->size == hist->cap)
{
content_history_free_entry(&hist->entries[hist->cap - 1]);
content_playlist_free_entry(&hist->entries[hist->cap - 1]);
hist->size--;
}
memmove(hist->entries + 1, hist->entries,
(hist->cap - 1) * sizeof(struct content_history_entry));
(hist->cap - 1) * sizeof(struct content_playlist_entry));
hist->entries[0].path = path ? strdup(path) : NULL;
hist->entries[0].core_path = strdup(core_path);
@ -115,7 +115,7 @@ void content_history_push(content_history_t *hist,
hist->size++;
}
static void content_history_write_file(content_history_t *hist)
static void content_playlist_write_file(content_playlist_t *hist)
{
size_t i;
FILE *file = NULL;
@ -127,7 +127,7 @@ static void content_history_write_file(content_history_t *hist)
if (!file)
{
RARCH_ERR("Couldn't write to content history file: %s.\n", hist->conf_path);
RARCH_ERR("Couldn't write to content playlist file: %s.\n", hist->conf_path);
return;
}
@ -142,52 +142,52 @@ static void content_history_write_file(content_history_t *hist)
fclose(file);
}
void content_history_free(content_history_t *hist)
void content_playlist_free(content_playlist_t *hist)
{
size_t i;
if (!hist)
return;
if (hist->conf_path)
content_history_write_file(hist);
content_playlist_write_file(hist);
free(hist->conf_path);
for (i = 0; i < hist->cap; i++)
content_history_free_entry(&hist->entries[i]);
content_playlist_free_entry(&hist->entries[i]);
free(hist->entries);
free(hist);
}
void content_history_clear(content_history_t *hist)
void content_playlist_clear(content_playlist_t *hist)
{
size_t i;
if (!hist)
return;
for (i = 0; i < hist->cap; i++)
content_history_free_entry(&hist->entries[i]);
content_playlist_free_entry(&hist->entries[i]);
hist->size = 0;
}
size_t content_history_size(content_history_t *hist)
size_t content_playlist_size(content_playlist_t *hist)
{
if (hist)
return hist->size;
return 0;
}
static bool content_history_read_file(content_history_t *hist, const char *path)
static bool content_playlist_read_file(content_playlist_t *hist, const char *path)
{
char buf[3][PATH_MAX];
unsigned i;
struct content_history_entry *entry = NULL;
struct content_playlist_entry *entry = NULL;
char *last = NULL;
FILE *file = fopen(path, "r");
if (!file || !hist)
{
RARCH_ERR("Couldn't read content history file: %s.\n", path);
RARCH_ERR("Couldn't read content playlist file: %s.\n", path);
return true;
}
@ -221,66 +221,66 @@ end:
return true;
}
content_history_t *content_history_init(const char *path, size_t size)
content_playlist_t *content_playlist_init(const char *path, size_t size)
{
RARCH_LOG("Opening history: %s.\n", path);
content_history_t *hist = (content_history_t*)calloc(1, sizeof(*hist));
RARCH_LOG("Opening playlist: %s.\n", path);
content_playlist_t *hist = (content_playlist_t*)calloc(1, sizeof(*hist));
if (!hist)
{
RARCH_ERR("Cannot initialize content history.\n");
RARCH_ERR("Cannot initialize content playlist.\n");
return NULL;
}
hist->entries = (struct content_history_entry*)calloc(size, sizeof(*hist->entries));
hist->entries = (struct content_playlist_entry*)calloc(size, sizeof(*hist->entries));
if (!hist->entries)
goto error;
hist->cap = size;
if (!content_history_read_file(hist, path))
if (!content_playlist_read_file(hist, path))
goto error;
hist->conf_path = strdup(path);
return hist;
error:
content_history_free(hist);
content_playlist_free(hist);
return NULL;
}
const char* content_history_get_path(content_history_t *hist, unsigned index)
const char* content_playlist_get_path(content_playlist_t *hist, unsigned index)
{
const char *path, *core_path, *core_name = NULL;
if (!hist)
return "";
content_history_get_index(hist, index, &path, &core_path, &core_name);
content_playlist_get_index(hist, index, &path, &core_path, &core_name);
if (path)
return path;
return "";
}
const char *content_history_get_core_path(content_history_t *hist, unsigned index)
const char *content_playlist_get_core_path(content_playlist_t *hist, unsigned index)
{
const char *path, *core_path, *core_name = NULL;
if (!hist)
return "";
content_history_get_index(hist, index, &path, &core_path, &core_name);
content_playlist_get_index(hist, index, &path, &core_path, &core_name);
if (core_path)
return core_path;
return "";
}
const char *content_history_get_core_name(content_history_t *hist, unsigned index)
const char *content_playlist_get_core_name(content_playlist_t *hist, unsigned index)
{
const char *path, *core_path, *core_name = NULL;
if (!hist)
return "";
content_history_get_index(hist, index, &path, &core_path, &core_name);
content_playlist_get_index(hist, index, &path, &core_path, &core_name);
if (core_name)
return core_name;

View File

@ -22,29 +22,29 @@
extern "C" {
#endif
typedef struct content_history content_history_t;
typedef struct content_playlist content_playlist_t;
content_history_t *content_history_init(const char *path, size_t size);
void content_history_free(content_history_t *hist);
content_playlist_t *content_playlist_init(const char *path, size_t size);
void content_playlist_free(content_playlist_t *hist);
void content_history_clear(content_history_t *hist);
void content_playlist_clear(content_playlist_t *hist);
size_t content_history_size(content_history_t *hist);
size_t content_playlist_size(content_playlist_t *hist);
void content_history_get_index(content_history_t *hist,
void content_playlist_get_index(content_playlist_t *hist,
size_t index,
const char **path, const char **core_path,
const char **core_name);
void content_history_push(content_history_t *hist,
void content_playlist_push(content_playlist_t *hist,
const char *path, const char *core_path,
const char *core_name);
const char* content_history_get_path(content_history_t *hist,
const char* content_playlist_get_path(content_playlist_t *hist,
unsigned index);
const char* content_history_get_core_path(content_history_t *hist,
const char* content_playlist_get_core_path(content_playlist_t *hist,
unsigned index);
const char* content_history_get_core_name(content_history_t *hist,
const char* content_playlist_get_core_name(content_playlist_t *hist,
unsigned index);
#ifdef __cplusplus

View File

@ -3212,11 +3212,11 @@ void rarch_main_command(unsigned action)
if (g_extern.history)
return;
g_extern.history = content_history_init(g_settings.content_history_path, g_settings.content_history_size);
g_extern.history = content_playlist_init(g_settings.content_history_path, g_settings.content_history_size);
break;
case RARCH_CMD_HISTORY_DEINIT:
if (g_extern.history)
content_history_free(g_extern.history);
content_playlist_free(g_extern.history);
g_extern.history = NULL;
break;
}