-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
/
Copy pathmanual_content_scan.h
278 lines (231 loc) · 9.5 KB
/
manual_content_scan.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
/* Copyright (C) 2010-2019 The RetroArch team
*
* ---------------------------------------------------------------------------------------
* The following license statement only applies to this file (manual_content_scan.c).
* ---------------------------------------------------------------------------------------
*
* 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.
*/
#ifndef __MANUAL_CONTENT_SCAN_H
#define __MANUAL_CONTENT_SCAN_H
#include <retro_common_api.h>
#include <libretro.h>
#include <boolean.h>
#include <lists/string_list.h>
#include <formats/logiqx_dat.h>
#include "playlist.h"
RETRO_BEGIN_DECLS
/* Defines all possible system name types
* > Use content directory name
* > Use custom name
* > Use database name */
enum manual_content_scan_system_name_type
{
MANUAL_CONTENT_SCAN_SYSTEM_NAME_CONTENT_DIR = 0,
MANUAL_CONTENT_SCAN_SYSTEM_NAME_CUSTOM,
MANUAL_CONTENT_SCAN_SYSTEM_NAME_DATABASE
};
/* Defines all possible core name types
* > Autodetect core (DETECT)
* > Use manually set core */
enum manual_content_scan_core_type
{
MANUAL_CONTENT_SCAN_CORE_DETECT = 0,
MANUAL_CONTENT_SCAN_CORE_SET
};
/* Defines all possible return values for
* manual_content_scan_validate_dat_file_path() */
enum manual_content_scan_dat_file_path_status
{
MANUAL_CONTENT_SCAN_DAT_FILE_UNSET = 0,
MANUAL_CONTENT_SCAN_DAT_FILE_OK,
MANUAL_CONTENT_SCAN_DAT_FILE_INVALID,
MANUAL_CONTENT_SCAN_DAT_FILE_TOO_LARGE
};
/* Defines all possible return values for
* manual_content_scan_set_menu_from_playlist() */
enum manual_content_scan_playlist_refresh_status
{
MANUAL_CONTENT_SCAN_PLAYLIST_REFRESH_OK = 0,
MANUAL_CONTENT_SCAN_PLAYLIST_REFRESH_MISSING_CONFIG,
MANUAL_CONTENT_SCAN_PLAYLIST_REFRESH_INVALID_CONTENT_DIR,
MANUAL_CONTENT_SCAN_PLAYLIST_REFRESH_INVALID_SYSTEM_NAME,
MANUAL_CONTENT_SCAN_PLAYLIST_REFRESH_INVALID_CORE,
MANUAL_CONTENT_SCAN_PLAYLIST_REFRESH_INVALID_DAT_FILE,
MANUAL_CONTENT_SCAN_PLAYLIST_REFRESH_DAT_FILE_TOO_LARGE
};
/* Holds all configuration parameters required
* for a manual content scan task */
typedef struct
{
char core_name[NAME_MAX_LENGTH];
char system_name[NAME_MAX_LENGTH];
char database_name[NAME_MAX_LENGTH];
char content_dir[DIR_MAX_LENGTH];
char playlist_file[PATH_MAX_LENGTH];
char core_path[PATH_MAX_LENGTH];
char file_exts[PATH_MAX_LENGTH];
char dat_file_path[PATH_MAX_LENGTH];
bool core_set;
bool file_exts_custom_set;
bool search_recursively;
bool search_archives;
bool filter_dat_content;
bool overwrite_playlist;
bool validate_entries;
} manual_content_scan_task_config_t;
/*****************/
/* Configuration */
/*****************/
/* Pointer access
* > This is a little ugly, but it allows us to
* make use of standard 'menu_settings' code
* for several config parameters (rather than
* implementing unnecessary custom menu entries) */
/* Returns a pointer to the internal
* 'content_dir' string */
char *manual_content_scan_get_content_dir_ptr(void);
/* Returns a pointer to the internal
* 'system_name_custom' string */
char *manual_content_scan_get_system_name_custom_ptr(void);
/* Returns size of the internal
* 'system_name_custom' string */
size_t manual_content_scan_get_system_name_custom_size(void);
/* Returns a pointer to the internal
* 'file_exts_custom' string */
char *manual_content_scan_get_file_exts_custom_ptr(void);
/* Returns size of the internal
* 'file_exts_custom' string */
size_t manual_content_scan_get_file_exts_custom_size(void);
/* Returns a pointer to the internal
* 'dat_file_path' string */
char *manual_content_scan_get_dat_file_path_ptr(void);
/* Returns size of the internal
* 'dat_file_path' string */
size_t manual_content_scan_get_dat_file_path_size(void);
/* Returns a pointer to the internal
* 'search_recursively' bool */
bool *manual_content_scan_get_search_recursively_ptr(void);
/* Returns a pointer to the internal
* 'search_archives' bool */
bool *manual_content_scan_get_search_archives_ptr(void);
/* Returns a pointer to the internal
* 'filter_dat_content' bool */
bool *manual_content_scan_get_filter_dat_content_ptr(void);
/* Returns a pointer to the internal
* 'overwrite_playlist' bool */
bool *manual_content_scan_get_overwrite_playlist_ptr(void);
/* Returns a pointer to the internal
* 'validate_entries' bool */
bool *manual_content_scan_get_validate_entries_ptr(void);
/* Sanitisation */
/* Removes invalid characters from
* 'system_name_custom' string */
void manual_content_scan_scrub_system_name_custom(void);
/* Removes period (full stop) characters from
* 'file_exts_custom' string and converts to
* lower case */
void manual_content_scan_scrub_file_exts_custom(void);
/* Checks 'dat_file_path' string and resets it
* if invalid */
enum manual_content_scan_dat_file_path_status
manual_content_scan_validate_dat_file_path(void);
/* Menu setters */
/* Sets content directory for next manual scan
* operation.
* Returns true if content directory is valid. */
bool manual_content_scan_set_menu_content_dir(const char *content_dir);
/* Sets system name for the next manual scan
* operation.
* Returns true if system name is valid.
* NOTE:
* > Only sets 'system_name_type' and 'system_name_database'
* > 'system_name_content_dir' and 'system_name_custom' are
* (by necessity) handled elsewhere
* > This may look fishy, but it's not - it's a menu-specific
* function, and this is simply the cleanest way to handle
* the setting... */
bool manual_content_scan_set_menu_system_name(
enum manual_content_scan_system_name_type system_name_type,
const char *system_name);
/* Sets core name for the next manual scan
* operation (+ core path and other associated
* parameters).
* Returns true if core name is valid. */
bool manual_content_scan_set_menu_core_name(
enum manual_content_scan_core_type core_type,
const char *core_name);
/* Sets all parameters for the next manual scan
* operation according the to recorded values in
* the specified playlist.
* Returns MANUAL_CONTENT_SCAN_PLAYLIST_REFRESH_OK
* if playlist contains a valid scan record. */
enum manual_content_scan_playlist_refresh_status
manual_content_scan_set_menu_from_playlist(playlist_t *playlist,
const char *path_content_database, bool show_hidden_files);
/* Menu getters */
/* Fetches content directory for next manual scan
* operation.
* Returns true if content directory is valid. */
bool manual_content_scan_get_menu_content_dir(const char **content_dir);
/* Fetches system name for the next manual scan operation.
* Returns true if system name is valid.
* NOTE: This corresponds to the 'System Name' value
* displayed in menus - this is not identical to the
* actual system name used when generating the playlist */
bool manual_content_scan_get_menu_system_name(const char **system_name);
/* Fetches core name for the next manual scan operation.
* Returns true if core name is valid. */
bool manual_content_scan_get_menu_core_name(const char **core_name);
/* Menu utility functions */
/* Creates a list of all possible 'system name' menu
* strings, for use in 'menu_displaylist' drop-down
* lists and 'menu_cbs_left/right'
* > Returns NULL in the event of failure
* > Returned string list must be free()'d */
struct string_list *manual_content_scan_get_menu_system_name_list(
const char *path_content_database, bool show_hidden_files);
/* Creates a list of all possible 'core name' menu
* strings, for use in 'menu_displaylist' drop-down
* lists and 'menu_cbs_left/right'
* > Returns NULL in the event of failure
* > Returned string list must be free()'d */
struct string_list *manual_content_scan_get_menu_core_name_list(void);
/****************/
/* Task Helpers */
/****************/
/* Parses current manual content scan settings,
* and extracts all information required to configure
* a manual content scan task.
* Returns false if current settings are invalid. */
bool manual_content_scan_get_task_config(
manual_content_scan_task_config_t *task_config,
const char *path_dir_playlist
);
/* Creates a list of all valid content in the specified
* content directory
* > Returns NULL in the event of failure
* > Returned string list must be free()'d */
struct string_list *manual_content_scan_get_content_list(
manual_content_scan_task_config_t *task_config);
/* Adds specified content to playlist, if not already
* present */
void manual_content_scan_add_content_to_playlist(
manual_content_scan_task_config_t *task_config,
playlist_t *playlist, const char *content_path,
int content_type, logiqx_dat_t *dat_file);
RETRO_END_DECLS
#endif