2017-01-22 13:58:20 +01:00
|
|
|
/* Copyright (C) 2010-2017 The RetroArch team
|
2012-01-08 02:30:32 +01:00
|
|
|
*
|
2014-10-21 19:23:28 +02:00
|
|
|
* ---------------------------------------------------------------------------------------
|
|
|
|
* The following license statement only applies to this file (file_list.h).
|
|
|
|
* ---------------------------------------------------------------------------------------
|
2012-01-08 02:30:32 +01:00
|
|
|
*
|
2014-10-21 19:23:28 +02:00
|
|
|
* Permission is hereby granted, free of charge,
|
|
|
|
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
|
|
|
* to deal in the Software without restriction, including without limitation the rights to
|
|
|
|
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
|
|
|
|
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
|
|
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
|
|
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
|
|
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
2012-01-08 02:30:32 +01:00
|
|
|
*/
|
|
|
|
|
2014-10-21 19:23:28 +02:00
|
|
|
#ifndef __LIBRETRO_SDK_FILE_LIST_H__
|
|
|
|
#define __LIBRETRO_SDK_FILE_LIST_H__
|
2012-01-08 00:57:44 +01:00
|
|
|
|
2016-04-23 10:40:46 +02:00
|
|
|
#include <retro_common_api.h>
|
|
|
|
|
|
|
|
RETRO_BEGIN_DECLS
|
2012-01-08 00:57:44 +01:00
|
|
|
|
2015-10-11 15:46:55 +02:00
|
|
|
#include <stddef.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
2014-10-21 05:05:52 +02:00
|
|
|
#include <boolean.h>
|
2013-12-09 16:18:58 +01:00
|
|
|
|
2014-08-09 00:56:27 +02:00
|
|
|
struct item_file
|
|
|
|
{
|
|
|
|
char *path;
|
|
|
|
char *label;
|
|
|
|
char *alt;
|
|
|
|
unsigned type;
|
|
|
|
size_t directory_ptr;
|
2015-06-10 22:43:06 +02:00
|
|
|
size_t entry_idx;
|
2014-10-10 22:08:11 +02:00
|
|
|
void *userdata;
|
2014-10-12 00:10:44 +02:00
|
|
|
void *actiondata;
|
2014-08-09 00:56:27 +02:00
|
|
|
};
|
|
|
|
|
2013-11-08 04:48:31 +01:00
|
|
|
typedef struct file_list
|
2013-03-16 09:55:08 +01:00
|
|
|
{
|
2013-11-08 04:50:33 +01:00
|
|
|
struct item_file *list;
|
2013-03-16 09:55:08 +01:00
|
|
|
|
|
|
|
size_t capacity;
|
|
|
|
size_t size;
|
2013-11-08 04:48:31 +01:00
|
|
|
} file_list_t;
|
2012-01-08 00:57:44 +01:00
|
|
|
|
2014-08-09 00:56:27 +02:00
|
|
|
|
2014-10-10 22:08:11 +02:00
|
|
|
void *file_list_get_userdata_at_offset(const file_list_t *list,
|
|
|
|
size_t index);
|
|
|
|
|
2014-10-12 01:23:41 +02:00
|
|
|
void *file_list_get_actiondata_at_offset(const file_list_t *list,
|
|
|
|
size_t index);
|
|
|
|
|
2017-09-03 10:30:01 -03:00
|
|
|
/**
|
|
|
|
* @brief frees the list
|
|
|
|
*
|
|
|
|
* NOTE: This function will also free() the entries actiondata
|
|
|
|
* and userdata fields if they are non-null. If you store complex
|
|
|
|
* or non-contiguous data there, make sure you free it's fields
|
|
|
|
* before calling this function or you might get a memory leak.
|
|
|
|
*
|
|
|
|
* @param list
|
|
|
|
*/
|
2014-06-17 16:46:30 +02:00
|
|
|
void file_list_free(file_list_t *list);
|
2012-01-08 00:57:44 +01:00
|
|
|
|
2017-09-03 14:58:01 -03:00
|
|
|
/**
|
|
|
|
* @brief makes the list big enough to contain at least nitems
|
|
|
|
*
|
|
|
|
* This function will not change the capacity if nitems is smaller
|
|
|
|
* than the current capacity.
|
|
|
|
*
|
|
|
|
* @param list
|
|
|
|
* @param nitems
|
|
|
|
* @return whether or not the operation succeeded
|
|
|
|
*/
|
|
|
|
bool file_list_reserve(file_list_t *list, size_t nitems);
|
|
|
|
|
2016-03-21 20:20:24 +01:00
|
|
|
bool file_list_append(file_list_t *userdata, const char *path,
|
2015-06-10 22:43:06 +02:00
|
|
|
const char *label, unsigned type, size_t current_directory_ptr,
|
|
|
|
size_t entry_index);
|
2014-10-21 18:37:30 +02:00
|
|
|
|
2016-04-12 01:40:48 +07:00
|
|
|
bool file_list_prepend(file_list_t *list,
|
2016-04-11 18:02:50 +02:00
|
|
|
const char *path, const char *label,
|
|
|
|
unsigned type, size_t directory_ptr,
|
|
|
|
size_t entry_idx);
|
|
|
|
|
2014-06-17 16:46:30 +02:00
|
|
|
void file_list_pop(file_list_t *list, size_t *directory_ptr);
|
2014-10-21 18:37:30 +02:00
|
|
|
|
2014-06-17 16:46:30 +02:00
|
|
|
void file_list_clear(file_list_t *list);
|
2014-10-21 18:37:30 +02:00
|
|
|
|
2015-06-13 19:01:42 -03:00
|
|
|
void file_list_copy(const file_list_t *src, file_list_t *dst);
|
2012-01-08 00:57:44 +01:00
|
|
|
|
2014-06-17 16:46:30 +02:00
|
|
|
void file_list_get_last(const file_list_t *list,
|
2014-08-30 15:50:42 +02:00
|
|
|
const char **path, const char **label,
|
2015-06-10 22:43:06 +02:00
|
|
|
unsigned *type, size_t *entry_idx);
|
2012-01-08 00:57:44 +01:00
|
|
|
|
2014-10-15 07:40:19 +02:00
|
|
|
void *file_list_get_last_actiondata(const file_list_t *list);
|
|
|
|
|
2014-06-17 16:46:30 +02:00
|
|
|
size_t file_list_get_size(const file_list_t *list);
|
2014-10-21 18:37:30 +02:00
|
|
|
|
2014-06-17 16:46:30 +02:00
|
|
|
size_t file_list_get_directory_ptr(const file_list_t *list);
|
2014-05-31 19:22:23 +02:00
|
|
|
|
2014-06-17 16:46:30 +02:00
|
|
|
void file_list_get_at_offset(const file_list_t *list, size_t index,
|
2014-08-30 15:50:42 +02:00
|
|
|
const char **path, const char **label,
|
2015-06-10 22:43:06 +02:00
|
|
|
unsigned *type, size_t *entry_idx);
|
2015-06-11 21:03:28 +02:00
|
|
|
|
|
|
|
void file_list_free_userdata(const file_list_t *list, size_t index);
|
|
|
|
|
|
|
|
void file_list_free_actiondata(const file_list_t *list, size_t idx);
|
2012-01-08 00:57:44 +01:00
|
|
|
|
2014-09-01 23:40:23 +02:00
|
|
|
void file_list_set_label_at_offset(file_list_t *list, size_t index,
|
|
|
|
const char *label);
|
2014-10-21 18:37:30 +02:00
|
|
|
|
2014-09-01 23:40:23 +02:00
|
|
|
void file_list_get_label_at_offset(const file_list_t *list, size_t index,
|
|
|
|
const char **label);
|
|
|
|
|
2014-06-17 16:46:30 +02:00
|
|
|
void file_list_set_alt_at_offset(file_list_t *list, size_t index,
|
2013-10-04 17:33:21 +02:00
|
|
|
const char *alt);
|
2014-10-21 18:37:30 +02:00
|
|
|
|
2015-06-11 23:02:17 +02:00
|
|
|
void file_list_set_userdata(const file_list_t *list, size_t idx, void *ptr);
|
|
|
|
|
|
|
|
void file_list_set_actiondata(const file_list_t *list, size_t idx, void *ptr);
|
|
|
|
|
2014-06-17 16:46:30 +02:00
|
|
|
void file_list_get_alt_at_offset(const file_list_t *list, size_t index,
|
2013-10-04 17:33:21 +02:00
|
|
|
const char **alt);
|
|
|
|
|
2014-06-17 16:46:30 +02:00
|
|
|
void file_list_sort_on_alt(file_list_t *list);
|
2013-10-06 15:10:00 +02:00
|
|
|
|
2015-01-19 07:15:16 +01:00
|
|
|
void file_list_sort_on_type(file_list_t *list);
|
|
|
|
|
2014-09-02 05:10:54 +02:00
|
|
|
bool file_list_search(const file_list_t *list, const char *needle,
|
|
|
|
size_t *index);
|
2013-12-09 16:18:58 +01:00
|
|
|
|
2016-04-23 10:40:46 +02:00
|
|
|
RETRO_END_DECLS
|
2012-01-08 00:57:44 +01:00
|
|
|
|
2014-10-21 19:23:28 +02:00
|
|
|
#endif
|