Skip to content

Commit d938b78

Browse files
committed
Scan rework - preparatory changes
A batch of changes without changing the current behavior. Actual business logic changes will come in another PR soon(ish).
1 parent bd15d7c commit d938b78

17 files changed

Lines changed: 1172 additions & 1 deletion

intl/msg_hash_lbl.h

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3758,6 +3758,18 @@ MSG_HASH(
37583758
MENU_ENUM_LABEL_SCAN_FILE,
37593759
"scan_file"
37603760
)
3761+
MSG_HASH(
3762+
MENU_ENUM_LABEL_SCAN_TARGET_PLAYLIST,
3763+
"scan_target_playlist"
3764+
)
3765+
MSG_HASH(
3766+
MENU_ENUM_LABEL_SCAN_SINGLE_FILE,
3767+
"scan_single_file"
3768+
)
3769+
MSG_HASH(
3770+
MENU_ENUM_LABEL_SCAN_OMIT_DB_REF,
3771+
"scan_omit_db_ref"
3772+
)
37613773
MSG_HASH(
37623774
MENU_ENUM_LABEL_NETPLAY_SHOW_ONLY_CONNECTABLE,
37633775
"netplay_show_only_connectable"
@@ -6562,6 +6574,30 @@ MSG_HASH(
65626574
MENU_ENUM_LABEL_MANUAL_CONTENT_SCAN_DIR,
65636575
"manual_content_scan_dir"
65646576
)
6577+
MSG_HASH(
6578+
MENU_ENUM_LABEL_SCAN_METHOD,
6579+
"scan_method"
6580+
)
6581+
MSG_HASH(
6582+
MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_SCAN_METHOD,
6583+
"deferred_dropdown_box_list_scan_method"
6584+
)
6585+
MSG_HASH(
6586+
MENU_ENUM_LABEL_SCAN_USE_DB,
6587+
"scan_use_db"
6588+
)
6589+
MSG_HASH(
6590+
MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_SCAN_USE_DB,
6591+
"deferred_dropdown_box_list_scan_use_db"
6592+
)
6593+
MSG_HASH(
6594+
MENU_ENUM_LABEL_SCAN_DB_SELECT,
6595+
"scan_db_select"
6596+
)
6597+
MSG_HASH(
6598+
MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_SCAN_DB_SELECT,
6599+
"deferred_dropdown_box_list_scan_db_select"
6600+
)
65656601
MSG_HASH(
65666602
MENU_ENUM_LABEL_MANUAL_CONTENT_SCAN_SYSTEM_NAME,
65676603
"manual_content_scan_system_name"

intl/msg_hash_us.h

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8886,6 +8886,54 @@ MSG_HASH(
88868886
MENU_ENUM_LABEL_VALUE_SCAN_ENTRY,
88878887
"Scan"
88888888
)
8889+
MSG_HASH(
8890+
MENU_ENUM_LABEL_VALUE_SCAN_METHOD,
8891+
"Scan Method"
8892+
)
8893+
MSG_HASH(
8894+
MENU_ENUM_SUBLABEL_SCAN_METHOD,
8895+
"Automatic or custom with detailed options."
8896+
)
8897+
MSG_HASH(
8898+
MENU_ENUM_LABEL_VALUE_SCAN_USE_DB,
8899+
"Database Check"
8900+
)
8901+
MSG_HASH(
8902+
MENU_ENUM_SUBLABEL_SCAN_USE_DB,
8903+
"Strict will only add items that match a database entry, Loose will add also files with correct extension but no CRC/serial match, Custom DAT checks against a user provided XML file instead of databases, None ignores databases and only uses file extensions."
8904+
)
8905+
MSG_HASH(
8906+
MENU_ENUM_LABEL_VALUE_SCAN_DB_SELECT,
8907+
"Database To Match"
8908+
)
8909+
MSG_HASH(
8910+
MENU_ENUM_SUBLABEL_SCAN_DB_SELECT,
8911+
"Matching can be restricted to one specific database, or to the very first database that matches, to speed up scanning."
8912+
)
8913+
MSG_HASH(
8914+
MENU_ENUM_LABEL_VALUE_SCAN_TARGET_PLAYLIST,
8915+
"Playlist To Update"
8916+
)
8917+
MSG_HASH(
8918+
MENU_ENUM_SUBLABEL_SCAN_TARGET_PLAYLIST,
8919+
"Results are added to this playlist. In case of Auto - Any, multiple system playlists may be updated. Custom without database reference will not link the entries to any database in the playlist."
8920+
)
8921+
MSG_HASH(
8922+
MENU_ENUM_LABEL_VALUE_SCAN_SINGLE_FILE,
8923+
"Scan Single File"
8924+
)
8925+
MSG_HASH(
8926+
MENU_ENUM_SUBLABEL_SCAN_SINGLE_FILE,
8927+
"Scans only one file instead of a directory. Re-select content location after changing this entry."
8928+
)
8929+
MSG_HASH(
8930+
MENU_ENUM_LABEL_VALUE_SCAN_OMIT_DB_REF,
8931+
"Skip Database References From Playlist"
8932+
)
8933+
MSG_HASH(
8934+
MENU_ENUM_SUBLABEL_SCAN_OMIT_DB_REF,
8935+
"In case of custom playlist name, always use the playlist name for thumbnail search, even if there was a database match."
8936+
)
88898937

88908938
/* Import Content > Scan File */
88918939

@@ -11528,6 +11576,10 @@ MSG_HASH(
1152811576
MENU_ENUM_LABEL_VALUE_MANUAL_CONTENT_SCAN_SYSTEM_NAME_USE_CONTENT_DIR,
1152911577
"<Content Directory>"
1153011578
)
11579+
MSG_HASH(
11580+
MENU_ENUM_LABEL_VALUE_MANUAL_CONTENT_SCAN_SYSTEM_NAME_USE_AUTO,
11581+
"<Automatic>"
11582+
)
1153111583
MSG_HASH(
1153211584
MENU_ENUM_LABEL_VALUE_MANUAL_CONTENT_SCAN_SYSTEM_NAME_USE_CUSTOM,
1153311585
"<Custom>"
@@ -11536,6 +11588,50 @@ MSG_HASH(
1153611588
MENU_ENUM_LABEL_VALUE_MANUAL_CONTENT_SCAN_CORE_NAME_DETECT,
1153711589
"<Unspecified>"
1153811590
)
11591+
MSG_HASH(
11592+
MENU_ENUM_LABEL_VALUE_SCAN_METHOD_AUTO,
11593+
"Fully Automatic"
11594+
)
11595+
MSG_HASH(
11596+
MENU_ENUM_LABEL_VALUE_SCAN_METHOD_CUSTOM,
11597+
"Custom"
11598+
)
11599+
MSG_HASH(
11600+
MENU_ENUM_LABEL_VALUE_SCAN_USE_DB_STRICT,
11601+
"Strict"
11602+
)
11603+
MSG_HASH(
11604+
MENU_ENUM_LABEL_VALUE_SCAN_USE_DB_LOOSE,
11605+
"Loose"
11606+
)
11607+
MSG_HASH(
11608+
MENU_ENUM_LABEL_VALUE_SCAN_USE_DB_CUSTOM_DAT,
11609+
"Custom DAT (Strict)"
11610+
)
11611+
MSG_HASH(
11612+
MENU_ENUM_LABEL_VALUE_SCAN_USE_DB_CUSTOM_DAT_LOOSE,
11613+
"Custom DAT (Loose)"
11614+
)
11615+
MSG_HASH(
11616+
MENU_ENUM_LABEL_VALUE_SCAN_USE_DB_NONE,
11617+
"None"
11618+
)
11619+
MSG_HASH(
11620+
MENU_ENUM_LABEL_VALUE_SCAN_DB_SELECT_AUTO_ANY,
11621+
"<Automatic/Any>"
11622+
)
11623+
MSG_HASH(
11624+
MENU_ENUM_LABEL_VALUE_SCAN_DB_SELECT_AUTO_FIRST,
11625+
"<Automatic/First match>"
11626+
)
11627+
MSG_HASH(
11628+
MENU_ENUM_LABEL_VALUE_SCAN_TARGET_PLAYLIST_AUTO_ANY,
11629+
"<Automatic/System name>"
11630+
)
11631+
MSG_HASH(
11632+
MENU_ENUM_LABEL_VALUE_SCAN_TARGET_PLAYLIST_CUSTOM,
11633+
"<Custom>"
11634+
)
1153911635
MSG_HASH(
1154011636
MENU_ENUM_LABEL_VALUE_LEFT_ANALOG,
1154111637
"Left Analog"

manual_content_scan.c

Lines changed: 185 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,16 @@ char *manual_content_scan_get_content_dir_ptr(void)
101101
return scan_settings.content_dir;
102102
}
103103

104+
unsigned manual_content_scan_get_scan_method_enum(void)
105+
{
106+
return 0;
107+
}
108+
109+
unsigned manual_content_scan_get_scan_use_db_enum(void)
110+
{
111+
return 0;
112+
}
113+
104114
/* Returns a pointer to the internal
105115
* 'system_name_custom' string */
106116
char *manual_content_scan_get_system_name_custom_ptr(void)
@@ -157,6 +167,16 @@ bool *manual_content_scan_get_search_archives_ptr(void)
157167
return &scan_settings.search_archives;
158168
}
159169

170+
bool *manual_content_scan_get_scan_single_file_ptr(void)
171+
{
172+
return NULL;
173+
}
174+
175+
bool *manual_content_scan_get_omit_db_ref_ptr(void)
176+
{
177+
return NULL;
178+
}
179+
160180
/* Returns a pointer to the internal
161181
* 'filter_dat_content' bool */
162182
bool *manual_content_scan_get_filter_dat_content_ptr(void)
@@ -334,6 +354,25 @@ bool manual_content_scan_set_menu_content_dir(const char *content_dir)
334354
return false;
335355
}
336356

357+
bool manual_content_scan_set_menu_scan_method(
358+
enum manual_content_scan_method method)
359+
{
360+
return true;
361+
}
362+
363+
bool manual_content_scan_set_menu_scan_use_db(
364+
enum manual_content_scan_db_usage usage)
365+
{
366+
return true;
367+
}
368+
369+
bool manual_content_scan_set_menu_scan_db_select(
370+
enum manual_content_scan_db_selection select,
371+
const char *db_name)
372+
{
373+
return false;
374+
}
375+
337376
/* Sets system name for the next manual scan
338377
* operation.
339378
* Returns true if system name is valid.
@@ -696,6 +735,26 @@ bool manual_content_scan_get_menu_content_dir(const char **content_dir)
696735
return true;
697736
}
698737

738+
bool manual_content_scan_get_menu_scan_method(const char **scan_method)
739+
{
740+
return false;
741+
}
742+
743+
bool manual_content_scan_get_menu_scan_use_db(const char **scan_use_db)
744+
{
745+
return false;
746+
}
747+
748+
unsigned manual_content_scan_get_scan_db_select_enum(void)
749+
{
750+
return 0;
751+
}
752+
753+
bool manual_content_scan_get_menu_scan_db_select(const char **scan_db_select)
754+
{
755+
return false;
756+
}
757+
699758
/* Fetches system name for the next manual scan operation.
700759
* Returns true if system name is valid.
701760
* NOTE: This corresponds to the 'System Name' value
@@ -730,6 +789,10 @@ bool manual_content_scan_get_menu_system_name(const char **system_name)
730789
return false;
731790
}
732791

792+
unsigned manual_content_scan_get_menu_system_name_type(void)
793+
{
794+
return 0;
795+
}
733796
/* Fetches core name for the next manual scan operation.
734797
* Returns true if core name is valid. */
735798
bool manual_content_scan_get_menu_core_name(const char **core_name)
@@ -759,6 +822,128 @@ bool manual_content_scan_get_menu_core_name(const char **core_name)
759822

760823
/* Menu utility functions */
761824

825+
826+
struct string_list *manual_content_scan_get_menu_scan_method_list(void)
827+
{
828+
return NULL;
829+
830+
}
831+
832+
struct string_list *manual_content_scan_get_menu_scan_use_db_list(void)
833+
{
834+
union string_list_elem_attr attr;
835+
struct string_list *name_list = string_list_new();
836+
837+
/* Sanity check */
838+
if (!name_list)
839+
return NULL;
840+
841+
attr.i = 0;
842+
843+
if (!string_list_append(name_list, msg_hash_to_str(
844+
MENU_ENUM_LABEL_VALUE_SCAN_USE_DB_STRICT), attr))
845+
goto error;
846+
847+
if (!string_list_append(name_list, msg_hash_to_str(
848+
MENU_ENUM_LABEL_VALUE_SCAN_USE_DB_LOOSE), attr))
849+
goto error;
850+
851+
if (!string_list_append(name_list, msg_hash_to_str(
852+
MENU_ENUM_LABEL_VALUE_SCAN_USE_DB_CUSTOM_DAT), attr))
853+
goto error;
854+
855+
if (!string_list_append(name_list, msg_hash_to_str(
856+
MENU_ENUM_LABEL_VALUE_SCAN_USE_DB_CUSTOM_DAT_LOOSE), attr))
857+
goto error;
858+
859+
if (!string_list_append(name_list, msg_hash_to_str(
860+
MENU_ENUM_LABEL_VALUE_SCAN_USE_DB_NONE), attr))
861+
goto error;
862+
863+
return name_list;
864+
865+
error:
866+
if (name_list)
867+
string_list_free(name_list);
868+
return NULL;
869+
870+
}
871+
872+
873+
struct string_list *manual_content_scan_get_menu_scan_db_select_list(
874+
const char *path_content_database, bool show_hidden_files)
875+
{
876+
union string_list_elem_attr attr;
877+
struct string_list *name_list = string_list_new();
878+
879+
/* Sanity check */
880+
if (!name_list)
881+
return NULL;
882+
883+
attr.i = 0;
884+
885+
/* Add 'use content directory' entry */
886+
if (!string_list_append(name_list, msg_hash_to_str(
887+
MENU_ENUM_LABEL_VALUE_SCAN_DB_SELECT_AUTO_ANY), attr))
888+
goto error;
889+
890+
/* Add 'use custom' entry */
891+
if (!string_list_append(name_list, msg_hash_to_str(
892+
MENU_ENUM_LABEL_VALUE_SCAN_DB_SELECT_AUTO_FIRST), attr))
893+
goto error;
894+
895+
#ifdef HAVE_LIBRETRODB
896+
/* If platform has database support, get names
897+
* of all installed database files */
898+
{
899+
/* Note: dir_list_new_special() is well behaved - the
900+
* returned string list will only include database
901+
* files (i.e. don't have to check for directories,
902+
* or verify file extensions) */
903+
struct string_list *rdb_list = dir_list_new_special(
904+
path_content_database,
905+
DIR_LIST_DATABASES, NULL, show_hidden_files);
906+
907+
if (rdb_list && rdb_list->size)
908+
{
909+
unsigned i;
910+
911+
/* Ensure database list is in alphabetical order */
912+
dir_list_sort(rdb_list, true);
913+
914+
/* Loop over database files */
915+
for (i = 0; i < rdb_list->size; i++)
916+
{
917+
char rdb_name[NAME_MAX_LENGTH];
918+
const char *rdb_path = rdb_list->elems[i].data;
919+
/* Sanity check */
920+
if (string_is_empty(rdb_path))
921+
continue;
922+
fill_pathname(rdb_name, path_basename(rdb_path), "",
923+
sizeof(rdb_name));
924+
if (string_is_empty(rdb_name))
925+
continue;
926+
/* Add database name to list */
927+
if (!string_list_append(name_list, rdb_name, attr))
928+
goto error;
929+
}
930+
}
931+
932+
/* Clean up */
933+
string_list_free(rdb_list);
934+
}
935+
936+
#endif
937+
938+
return name_list;
939+
940+
error:
941+
if (name_list)
942+
string_list_free(name_list);
943+
return NULL;
944+
}
945+
946+
762947
/* Creates a list of all possible 'system name' menu
763948
* strings, for use in 'menu_displaylist' drop-down
764949
* lists and 'menu_cbs_left/right'

0 commit comments

Comments
 (0)