core/tags/track: Add track_match_token() function

This is used to check if a track has a token that begins with the
requested string.

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
Anna Schumaker 2016-05-19 12:27:34 -04:00 committed by Anna Schumaker
parent 6ad4325f22
commit d16e06111d
3 changed files with 13 additions and 0 deletions

View File

@ -310,6 +310,12 @@ int track_compare(struct track *lhs, struct track *rhs, enum compare_t compare)
return 0; /* We should never get here. */
}
bool track_match_token(struct track *track, const gchar *token)
{
return string_match_token(token, track->tr_tokens) ||
string_match_token(token, track->tr_alts);
}
gchar *track_path(struct track *track)
{
gchar *path, *res;

View File

@ -99,6 +99,9 @@ struct track *track_get(const unsigned int);
/* Called to compare two track tags */
int track_compare(struct track *, struct track *, enum compare_t);
/* Called to check if a track has a token that matches the given string */
bool track_match_token(struct track *, const gchar *);
/*
* Called to find the full path of the track tag.
* This function returns a new string that MUST be freed with g_free().

View File

@ -91,6 +91,10 @@ static void test_track()
test_verify_track(track);
test_equal(library->li_size, 1);
test_equal(track_match_token(track, "title"), (bool)true);
test_equal(track_match_token(track, "theme"), (bool)true);
test_equal(track_match_token(track, "hyrule"), (bool)false);
file_open(&f, OPEN_WRITE);
file_writef(&f, "0 0 0 0 0 0 0 0 0 0 \n");
file_writef(&f, "Hyrule Symphony/00 - No Track.ogg\n");