1 /* Copyright (C) 2010-2020 The RetroArch team
3 * ---------------------------------------------------------------------------------------
4 * The following license statement only applies to this file (file_list.h).
5 * ---------------------------------------------------------------------------------------
7 * Permission is hereby granted, free of charge,
8 * to any person obtaining a copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation the rights to
10 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
11 * and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
16 * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
19 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 #ifndef __LIBRETRO_SDK_FILE_LIST_H__
24 #define __LIBRETRO_SDK_FILE_LIST_H__
26 #include <retro_common_api.h>
47 typedef struct file_list
49 struct item_file *list;
55 void *file_list_get_userdata_at_offset(const file_list_t *list,
58 void *file_list_get_actiondata_at_offset(const file_list_t *list,
62 * @brief frees the list
64 * NOTE: This function will also free() the entries actiondata
65 * and userdata fields if they are non-null. If you store complex
66 * or non-contiguous data there, make sure you free it's fields
67 * before calling this function or you might get a memory leak.
69 * @param list List to be freed
71 void file_list_free(file_list_t *list);
73 bool file_list_deinitialize(file_list_t *list);
76 * @brief makes the list big enough to contain at least nitems
78 * This function will not change the capacity if nitems is smaller
79 * than the current capacity.
81 * @param list The list to open for input
82 * @param nitems Number of items to reserve space for
83 * @return whether or not the operation succeeded
85 bool file_list_reserve(file_list_t *list, size_t nitems);
87 bool file_list_append(file_list_t *userdata, const char *path,
88 const char *label, unsigned type, size_t current_directory_ptr,
91 bool file_list_insert(file_list_t *list,
92 const char *path, const char *label,
93 unsigned type, size_t directory_ptr,
97 void file_list_pop(file_list_t *list, size_t *directory_ptr);
99 void file_list_clear(file_list_t *list);
101 void file_list_free_userdata(const file_list_t *list, size_t index);
103 void file_list_free_actiondata(const file_list_t *list, size_t idx);
105 void file_list_set_alt_at_offset(file_list_t *list, size_t index,
108 void file_list_sort_on_alt(file_list_t *list);
110 void file_list_sort_on_type(file_list_t *list);
112 bool file_list_search(const file_list_t *list, const char *needle,