2013-04-27 22:15:59 +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-04-12 16:50:27 +00:00
|
|
|
* Copyright (C) 2016-2019 - Brad Parker
|
2017-12-12 07:55:31 +00:00
|
|
|
*
|
2013-04-27 22:15:59 +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-05-16 07:07:44 +00:00
|
|
|
#ifndef _PLAYLIST_H__
|
|
|
|
#define _PLAYLIST_H__
|
2013-04-27 22:15:59 +00:00
|
|
|
|
|
|
|
#include <stddef.h>
|
|
|
|
|
2016-06-03 00:39:35 +00:00
|
|
|
#include <retro_common_api.h>
|
2016-07-30 19:27:40 +00:00
|
|
|
#include <boolean.h>
|
2019-04-11 04:09:13 +00:00
|
|
|
#include <lists/string_list.h>
|
2016-06-03 00:39:35 +00:00
|
|
|
|
2020-06-06 12:49:34 +00:00
|
|
|
#include "core_info.h"
|
|
|
|
|
2016-06-03 00:39:35 +00:00
|
|
|
RETRO_BEGIN_DECLS
|
2013-04-28 00:01:25 +00:00
|
|
|
|
2019-07-30 16:11:43 +00:00
|
|
|
/* Default maximum playlist size */
|
2020-08-07 13:07:05 +00:00
|
|
|
#define COLLECTION_SIZE 0x7FFFFFFF
|
2019-07-30 16:11:43 +00:00
|
|
|
|
2019-04-12 16:50:27 +00:00
|
|
|
typedef struct content_playlist playlist_t;
|
|
|
|
|
2019-05-09 13:24:06 +00:00
|
|
|
enum playlist_runtime_status
|
|
|
|
{
|
|
|
|
PLAYLIST_RUNTIME_UNKNOWN = 0,
|
|
|
|
PLAYLIST_RUNTIME_MISSING,
|
|
|
|
PLAYLIST_RUNTIME_VALID
|
|
|
|
};
|
|
|
|
|
2019-07-18 19:15:13 +00:00
|
|
|
enum playlist_file_mode
|
|
|
|
{
|
2019-08-15 17:04:24 +00:00
|
|
|
PLAYLIST_LOAD = 0,
|
|
|
|
PLAYLIST_SAVE
|
2019-07-18 19:15:13 +00:00
|
|
|
};
|
|
|
|
|
2019-07-18 17:11:30 +00:00
|
|
|
enum playlist_label_display_mode
|
|
|
|
{
|
|
|
|
LABEL_DISPLAY_MODE_DEFAULT = 0,
|
|
|
|
LABEL_DISPLAY_MODE_REMOVE_PARENTHESES,
|
|
|
|
LABEL_DISPLAY_MODE_REMOVE_BRACKETS,
|
|
|
|
LABEL_DISPLAY_MODE_REMOVE_PARENTHESES_AND_BRACKETS,
|
|
|
|
LABEL_DISPLAY_MODE_KEEP_REGION,
|
|
|
|
LABEL_DISPLAY_MODE_KEEP_DISC_INDEX,
|
|
|
|
LABEL_DISPLAY_MODE_KEEP_REGION_AND_DISC_INDEX
|
|
|
|
};
|
|
|
|
|
2019-08-15 17:04:24 +00:00
|
|
|
enum playlist_thumbnail_mode
|
|
|
|
{
|
|
|
|
PLAYLIST_THUMBNAIL_MODE_DEFAULT = 0,
|
|
|
|
PLAYLIST_THUMBNAIL_MODE_OFF,
|
|
|
|
PLAYLIST_THUMBNAIL_MODE_SCREENSHOTS,
|
|
|
|
PLAYLIST_THUMBNAIL_MODE_TITLE_SCREENS,
|
|
|
|
PLAYLIST_THUMBNAIL_MODE_BOXARTS
|
|
|
|
};
|
|
|
|
|
2020-04-10 16:05:23 +00:00
|
|
|
enum playlist_sort_mode
|
|
|
|
{
|
|
|
|
PLAYLIST_SORT_MODE_DEFAULT = 0,
|
|
|
|
PLAYLIST_SORT_MODE_ALPHABETICAL,
|
|
|
|
PLAYLIST_SORT_MODE_OFF
|
|
|
|
};
|
|
|
|
|
2020-02-16 15:38:17 +00:00
|
|
|
/* TODO/FIXME - since gfx_thumbnail_path.h has now
|
|
|
|
* been divorced from the menu code, perhaps jdgleaver
|
|
|
|
* can refactor this? */
|
|
|
|
|
2019-08-15 17:04:24 +00:00
|
|
|
/* Note: We already have a left/right enum defined
|
2020-02-16 15:38:17 +00:00
|
|
|
* in gfx_thumbnail_path.h - but we can't include
|
2019-08-15 17:04:24 +00:00
|
|
|
* menu code here, so have to make a 'duplicate'... */
|
|
|
|
enum playlist_thumbnail_id
|
|
|
|
{
|
|
|
|
PLAYLIST_THUMBNAIL_RIGHT = 0,
|
|
|
|
PLAYLIST_THUMBNAIL_LEFT
|
|
|
|
};
|
|
|
|
|
2019-04-12 16:50:27 +00:00
|
|
|
struct playlist_entry
|
|
|
|
{
|
|
|
|
char *path;
|
|
|
|
char *label;
|
|
|
|
char *core_path;
|
|
|
|
char *core_name;
|
|
|
|
char *db_name;
|
|
|
|
char *crc32;
|
|
|
|
char *subsystem_ident;
|
|
|
|
char *subsystem_name;
|
2019-09-10 15:13:25 +00:00
|
|
|
char *runtime_str;
|
|
|
|
char *last_played_str;
|
2019-04-12 16:50:27 +00:00
|
|
|
struct string_list *subsystem_roms;
|
|
|
|
unsigned runtime_hours;
|
|
|
|
unsigned runtime_minutes;
|
|
|
|
unsigned runtime_seconds;
|
|
|
|
/* Note: due to platform dependence, have to record
|
|
|
|
* timestamp as either a string or independent integer
|
|
|
|
* values. The latter is more verbose, but more efficient. */
|
|
|
|
unsigned last_played_year;
|
|
|
|
unsigned last_played_month;
|
|
|
|
unsigned last_played_day;
|
|
|
|
unsigned last_played_hour;
|
|
|
|
unsigned last_played_minute;
|
|
|
|
unsigned last_played_second;
|
2020-08-14 15:00:50 +00:00
|
|
|
enum playlist_runtime_status runtime_status;
|
2019-04-12 16:50:27 +00:00
|
|
|
};
|
2013-04-27 22:15:59 +00:00
|
|
|
|
2020-06-26 14:39:03 +00:00
|
|
|
/* Holds all configuration parameters required
|
|
|
|
* when initialising/saving playlists */
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
size_t capacity;
|
|
|
|
bool old_format;
|
|
|
|
bool compress;
|
|
|
|
bool fuzzy_archive_match;
|
2020-07-23 18:08:43 +00:00
|
|
|
bool autofix_paths;
|
2020-08-14 15:00:50 +00:00
|
|
|
char path[PATH_MAX_LENGTH];
|
|
|
|
char base_content_directory[PATH_MAX_LENGTH];
|
2020-06-26 14:39:03 +00:00
|
|
|
} playlist_config_t;
|
|
|
|
|
|
|
|
/* Convenience function: copies specified playlist
|
|
|
|
* path to specified playlist configuration object */
|
|
|
|
void playlist_config_set_path(playlist_config_t *config, const char *path);
|
|
|
|
|
2020-07-23 18:08:43 +00:00
|
|
|
/* Convenience function: copies base content directory
|
|
|
|
* path to specified playlist configuration object */
|
|
|
|
void playlist_config_set_base_content_directory(playlist_config_t* config, const char* path);
|
|
|
|
|
2020-06-26 14:39:03 +00:00
|
|
|
/* Creates a copy of the specified playlist configuration.
|
|
|
|
* Returns false in the event of an error */
|
|
|
|
bool playlist_config_copy(const playlist_config_t *src, playlist_config_t *dst);
|
|
|
|
|
|
|
|
/* Returns internal playlist configuration object
|
|
|
|
* of specified playlist.
|
|
|
|
* Returns NULL it the event of an error. */
|
|
|
|
playlist_config_t *playlist_get_config(playlist_t *playlist);
|
|
|
|
|
2015-01-16 18:42:11 +00:00
|
|
|
/**
|
2016-05-16 07:07:44 +00:00
|
|
|
* playlist_init:
|
2020-06-26 14:39:03 +00:00
|
|
|
* @config : Playlist configuration object.
|
2015-01-16 18:42:11 +00:00
|
|
|
*
|
|
|
|
* Creates and initializes a playlist.
|
|
|
|
*
|
|
|
|
* Returns: handle to new playlist if successful, otherwise NULL
|
|
|
|
**/
|
2020-06-26 14:39:03 +00:00
|
|
|
playlist_t *playlist_init(const playlist_config_t *config);
|
2014-09-02 03:32:04 +00:00
|
|
|
|
2015-01-16 18:42:11 +00:00
|
|
|
/**
|
2016-05-16 07:07:44 +00:00
|
|
|
* playlist_free:
|
2015-01-17 02:48:59 +00:00
|
|
|
* @playlist : Playlist handle.
|
2015-01-16 18:42:11 +00:00
|
|
|
*
|
|
|
|
* Frees playlist handle.
|
|
|
|
*/
|
2016-05-16 07:07:44 +00:00
|
|
|
void playlist_free(playlist_t *playlist);
|
2013-04-27 22:15:59 +00:00
|
|
|
|
2015-01-16 18:42:11 +00:00
|
|
|
/**
|
2016-05-16 07:07:44 +00:00
|
|
|
* playlist_clear:
|
2015-01-17 02:48:59 +00:00
|
|
|
* @playlist : Playlist handle.
|
2015-01-16 18:42:11 +00:00
|
|
|
*
|
|
|
|
* Clears all playlist entries in playlist.
|
|
|
|
**/
|
2016-05-16 07:07:44 +00:00
|
|
|
void playlist_clear(playlist_t *playlist);
|
2013-12-16 02:27:17 +00:00
|
|
|
|
2015-01-16 19:19:21 +00:00
|
|
|
/**
|
2016-05-16 07:07:44 +00:00
|
|
|
* playlist_size:
|
2015-01-17 02:48:59 +00:00
|
|
|
* @playlist : Playlist handle.
|
2015-01-16 19:19:21 +00:00
|
|
|
*
|
|
|
|
* Gets size of playlist.
|
|
|
|
* Returns: size of playlist.
|
|
|
|
**/
|
2016-05-16 07:07:44 +00:00
|
|
|
size_t playlist_size(playlist_t *playlist);
|
2013-04-27 22:15:59 +00:00
|
|
|
|
2019-07-30 16:11:43 +00:00
|
|
|
/**
|
|
|
|
* playlist_capacity:
|
|
|
|
* @playlist : Playlist handle.
|
|
|
|
*
|
|
|
|
* Gets maximum capacity of playlist.
|
|
|
|
* Returns: maximum capacity of playlist.
|
|
|
|
**/
|
|
|
|
size_t playlist_capacity(playlist_t *playlist);
|
|
|
|
|
2015-01-16 19:19:21 +00:00
|
|
|
/**
|
2016-05-16 07:07:44 +00:00
|
|
|
* playlist_get_index:
|
2016-08-28 23:17:02 +00:00
|
|
|
* @playlist : Playlist handle.
|
2015-01-16 19:19:21 +00:00
|
|
|
* @idx : Index of playlist entry.
|
2017-12-12 07:55:31 +00:00
|
|
|
*
|
|
|
|
* Gets values of playlist index:
|
2015-01-16 19:19:21 +00:00
|
|
|
**/
|
2016-05-16 07:07:44 +00:00
|
|
|
void playlist_get_index(playlist_t *playlist,
|
2015-05-25 22:12:49 +00:00
|
|
|
size_t idx,
|
2019-04-12 16:50:27 +00:00
|
|
|
const struct playlist_entry **entry);
|
2013-04-27 22:15:59 +00:00
|
|
|
|
2016-08-28 23:17:02 +00:00
|
|
|
/**
|
|
|
|
* playlist_delete_index:
|
|
|
|
* @playlist : Playlist handle.
|
|
|
|
* @idx : Index of playlist entry.
|
2017-12-12 07:55:31 +00:00
|
|
|
*
|
|
|
|
* Deletes the entry at index:
|
2016-08-28 23:17:02 +00:00
|
|
|
**/
|
|
|
|
void playlist_delete_index(playlist_t *playlist,
|
|
|
|
size_t idx);
|
|
|
|
|
2020-03-20 14:26:08 +00:00
|
|
|
/**
|
|
|
|
* playlist_delete_by_path:
|
|
|
|
* @playlist : Playlist handle.
|
|
|
|
* @search_path : Content path.
|
|
|
|
*
|
|
|
|
* Deletes all entries with content path
|
|
|
|
* matching 'search_path'
|
|
|
|
**/
|
|
|
|
void playlist_delete_by_path(playlist_t *playlist,
|
2020-06-26 14:39:03 +00:00
|
|
|
const char *search_path);
|
2020-03-20 14:26:08 +00:00
|
|
|
|
2019-07-18 19:15:13 +00:00
|
|
|
/**
|
|
|
|
* playlist_resolve_path:
|
|
|
|
* @mode : PLAYLIST_LOAD or PLAYLIST_SAVE
|
2020-08-31 11:12:09 +00:00
|
|
|
* @is_core : Set true if path to be resolved is a core file
|
|
|
|
* @path : The path to be modified
|
2019-07-18 19:15:13 +00:00
|
|
|
*
|
|
|
|
* Resolves the path of an item, such as the content path or path to the core, to a format
|
|
|
|
* appropriate for saving or loading depending on the @mode parameter
|
|
|
|
*
|
|
|
|
* Can be platform specific. File paths for saving can be abbreviated to avoid saving absolute
|
|
|
|
* paths, as the base directory (home or application dir) may change after each subsequent
|
|
|
|
* install (iOS)
|
|
|
|
**/
|
|
|
|
void playlist_resolve_path(enum playlist_file_mode mode,
|
2020-08-31 11:12:09 +00:00
|
|
|
bool is_core, char *path, size_t len);
|
2019-07-18 19:15:13 +00:00
|
|
|
|
2015-01-16 20:09:05 +00:00
|
|
|
/**
|
2016-05-16 07:07:44 +00:00
|
|
|
* playlist_push:
|
2015-01-17 02:48:59 +00:00
|
|
|
* @playlist : Playlist handle.
|
2015-01-16 20:09:05 +00:00
|
|
|
*
|
|
|
|
* Push entry to top of playlist.
|
|
|
|
**/
|
2016-07-30 19:27:40 +00:00
|
|
|
bool playlist_push(playlist_t *playlist,
|
2020-06-26 14:39:03 +00:00
|
|
|
const struct playlist_entry *entry);
|
2013-04-27 22:15:59 +00:00
|
|
|
|
2019-02-12 05:32:01 +00:00
|
|
|
bool playlist_push_runtime(playlist_t *playlist,
|
2020-06-26 14:39:03 +00:00
|
|
|
const struct playlist_entry *entry);
|
2019-02-12 05:32:01 +00:00
|
|
|
|
2016-05-16 07:07:44 +00:00
|
|
|
void playlist_update(playlist_t *playlist, size_t idx,
|
2019-04-12 16:50:27 +00:00
|
|
|
const struct playlist_entry *update_entry);
|
2015-05-26 04:28:16 +00:00
|
|
|
|
2019-03-01 14:06:40 +00:00
|
|
|
/* Note: register_update determines whether the internal
|
|
|
|
* 'playlist->modified' flag is set when updating runtime
|
|
|
|
* values. Since these are normally set temporarily (for
|
|
|
|
* display purposes), we do not always want this function
|
|
|
|
* to trigger a re-write of the playlist file. */
|
2019-02-12 05:32:01 +00:00
|
|
|
void playlist_update_runtime(playlist_t *playlist, size_t idx,
|
2019-05-09 13:24:06 +00:00
|
|
|
const struct playlist_entry *update_entry,
|
2019-03-01 14:06:40 +00:00
|
|
|
bool register_update);
|
2019-02-12 05:32:01 +00:00
|
|
|
|
2016-05-16 07:07:44 +00:00
|
|
|
void playlist_get_index_by_path(playlist_t *playlist,
|
2015-02-03 03:12:32 +00:00
|
|
|
const char *search_path,
|
2020-06-26 14:39:03 +00:00
|
|
|
const struct playlist_entry **entry);
|
2015-02-03 03:12:32 +00:00
|
|
|
|
2016-05-16 07:07:44 +00:00
|
|
|
bool playlist_entry_exists(playlist_t *playlist,
|
2020-06-26 14:39:03 +00:00
|
|
|
const char *path);
|
2016-01-26 20:21:01 +00:00
|
|
|
|
2017-07-01 01:38:36 +00:00
|
|
|
char *playlist_get_conf_path(playlist_t *playlist);
|
|
|
|
|
|
|
|
uint32_t playlist_get_size(playlist_t *playlist);
|
|
|
|
|
2020-06-26 14:39:03 +00:00
|
|
|
void playlist_write_file(playlist_t *playlist);
|
2015-05-25 16:46:16 +00:00
|
|
|
|
2019-02-12 05:32:01 +00:00
|
|
|
void playlist_write_runtime_file(playlist_t *playlist);
|
|
|
|
|
2016-08-28 16:47:34 +00:00
|
|
|
void playlist_qsort(playlist_t *playlist);
|
2015-06-11 13:04:35 +00:00
|
|
|
|
2018-04-10 15:40:29 +00:00
|
|
|
void playlist_free_cached(void);
|
|
|
|
|
|
|
|
playlist_t *playlist_get_cached(void);
|
|
|
|
|
2020-04-21 15:44:26 +00:00
|
|
|
/* If current on-disk playlist file referenced
|
2020-06-26 14:39:03 +00:00
|
|
|
* by 'config->path' does not match requested
|
|
|
|
* 'old format' or 'compression' state, file will
|
|
|
|
* be updated automatically
|
2020-04-21 15:44:26 +00:00
|
|
|
* > Since this function is called whenever a
|
|
|
|
* playlist is browsed via the menu, this is
|
|
|
|
* a simple method for ensuring that files
|
|
|
|
* are always kept synced with user settings */
|
2020-06-26 14:39:03 +00:00
|
|
|
bool playlist_init_cached(const playlist_config_t *config);
|
2018-04-10 15:40:29 +00:00
|
|
|
|
2019-01-20 00:57:24 +00:00
|
|
|
void command_playlist_push_write(
|
|
|
|
playlist_t *playlist,
|
2020-06-26 14:39:03 +00:00
|
|
|
const struct playlist_entry *entry);
|
2019-01-20 00:57:24 +00:00
|
|
|
|
|
|
|
void command_playlist_update_write(
|
|
|
|
playlist_t *playlist,
|
|
|
|
size_t idx,
|
2020-06-26 14:39:03 +00:00
|
|
|
const struct playlist_entry *entry);
|
2019-01-20 00:57:24 +00:00
|
|
|
|
2019-03-09 13:48:06 +00:00
|
|
|
/* Returns true if specified playlist index matches
|
|
|
|
* specified content/core paths */
|
|
|
|
bool playlist_index_is_valid(playlist_t *playlist, size_t idx,
|
|
|
|
const char *path, const char *core_path);
|
|
|
|
|
2020-01-15 17:59:15 +00:00
|
|
|
/* Returns true if specified playlist entries have
|
|
|
|
* identical content and core paths */
|
|
|
|
bool playlist_entries_are_equal(
|
|
|
|
const struct playlist_entry *entry_a,
|
|
|
|
const struct playlist_entry *entry_b,
|
2020-06-26 14:39:03 +00:00
|
|
|
const playlist_config_t *config);
|
2020-01-15 17:59:15 +00:00
|
|
|
|
2019-03-09 13:48:06 +00:00
|
|
|
void playlist_get_crc32(playlist_t *playlist, size_t idx,
|
|
|
|
const char **crc32);
|
|
|
|
|
|
|
|
/* If db_name is empty, 'returns' playlist file basename */
|
|
|
|
void playlist_get_db_name(playlist_t *playlist, size_t idx,
|
|
|
|
const char **db_name);
|
|
|
|
|
2019-06-26 16:40:00 +00:00
|
|
|
char *playlist_get_default_core_path(playlist_t *playlist);
|
|
|
|
char *playlist_get_default_core_name(playlist_t *playlist);
|
2019-07-18 17:11:30 +00:00
|
|
|
enum playlist_label_display_mode playlist_get_label_display_mode(playlist_t *playlist);
|
2019-08-15 17:04:24 +00:00
|
|
|
enum playlist_thumbnail_mode playlist_get_thumbnail_mode(
|
|
|
|
playlist_t *playlist, enum playlist_thumbnail_id thumbnail_id);
|
2020-04-10 16:05:23 +00:00
|
|
|
enum playlist_sort_mode playlist_get_sort_mode(playlist_t *playlist);
|
2019-06-26 16:40:00 +00:00
|
|
|
|
|
|
|
void playlist_set_default_core_path(playlist_t *playlist, const char *core_path);
|
|
|
|
void playlist_set_default_core_name(playlist_t *playlist, const char *core_name);
|
2019-07-18 17:11:30 +00:00
|
|
|
void playlist_set_label_display_mode(playlist_t *playlist, enum playlist_label_display_mode label_display_mode);
|
2019-08-15 17:04:24 +00:00
|
|
|
void playlist_set_thumbnail_mode(
|
|
|
|
playlist_t *playlist, enum playlist_thumbnail_id thumbnail_id, enum playlist_thumbnail_mode thumbnail_mode);
|
2020-04-10 16:05:23 +00:00
|
|
|
void playlist_set_sort_mode(playlist_t *playlist, enum playlist_sort_mode sort_mode);
|
2019-06-26 16:40:00 +00:00
|
|
|
|
2020-06-06 12:49:34 +00:00
|
|
|
/* Returns true if specified entry has a valid
|
|
|
|
* core association (i.e. a non-empty string
|
|
|
|
* other than DETECT) */
|
|
|
|
bool playlist_entry_has_core(const struct playlist_entry *entry);
|
|
|
|
|
|
|
|
/* Fetches core info object corresponding to the
|
|
|
|
* currently associated core of the specified
|
|
|
|
* playlist entry.
|
|
|
|
* Returns NULL if entry does not have a valid
|
|
|
|
* core association */
|
|
|
|
core_info_t *playlist_entry_get_core_info(const struct playlist_entry* entry);
|
|
|
|
|
|
|
|
/* Fetches core info object corresponding to the
|
|
|
|
* currently associated default core of the
|
|
|
|
* specified playlist.
|
|
|
|
* Returns NULL if playlist does not have a valid
|
|
|
|
* default core association */
|
|
|
|
core_info_t *playlist_get_default_core_info(playlist_t* playlist);
|
|
|
|
|
2020-07-30 15:53:01 +00:00
|
|
|
void playlist_set_cached_external(playlist_t* pl);
|
2020-07-28 08:47:26 +00:00
|
|
|
|
2016-06-03 00:39:35 +00:00
|
|
|
RETRO_END_DECLS
|
2013-04-28 00:01:25 +00:00
|
|
|
|
2013-04-27 22:15:59 +00:00
|
|
|
#endif
|