FS#12132 patch 6, part 2: tagnavi.config: Add support for "basename"

in formats and conditions.  The basename is the non-directory part of
a file's pathname.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30230 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Michael Hohmuth 2011-07-31 16:26:35 +00:00
parent accea18ded
commit eab7e74778
3 changed files with 21 additions and 4 deletions

View file

@ -871,6 +871,10 @@ static long check_virtual_tags(int tag, int idx_id,
- find_tag(tag_commitid, idx_id, idx) - 1; - find_tag(tag_commitid, idx_id, idx) - 1;
break; break;
case tag_virt_basename:
tag = tag_filename; /* return filename; caller handles basename */
/* FALLTHRU */
default: default:
data = find_tag(tag, idx_id, idx); data = find_tag(tag, idx_id, idx);
} }
@ -1011,7 +1015,8 @@ static bool check_clauses(struct tagcache_search *tcs,
if (!TAGCACHE_IS_NUMERIC(clause->tag)) if (!TAGCACHE_IS_NUMERIC(clause->tag))
{ {
if (clause->tag == tag_filename) if (clause->tag == tag_filename
|| clause->tag == tag_virt_basename)
{ {
retrieve(tcs, idx, tag_filename, buf, sizeof buf); retrieve(tcs, idx, tag_filename, buf, sizeof buf);
} }
@ -1029,7 +1034,11 @@ static bool check_clauses(struct tagcache_search *tcs,
if (!TAGCACHE_IS_NUMERIC(clause->tag)) if (!TAGCACHE_IS_NUMERIC(clause->tag))
{ {
int fd = tcs->idxfd[clause->tag]; int tag = clause->tag;
if (tag == tag_virt_basename)
tag = tag_filename;
int fd = tcs->idxfd[tag];
lseek(fd, seek, SEEK_SET); lseek(fd, seek, SEEK_SET);
ecread_tagfile_entry(fd, &tfe); ecread_tagfile_entry(fd, &tfe);
if (tfe.tag_length >= (int)sizeof(buf)) if (tfe.tag_length >= (int)sizeof(buf))
@ -1047,6 +1056,13 @@ static bool check_clauses(struct tagcache_search *tcs,
} }
} }
if (clause->tag == tag_virt_basename)
{
char *basename = strrchr(str, '/');
if (basename)
str = basename + 1;
}
if (!check_against_clause(seek, str, clause)) if (!check_against_clause(seek, str, clause))
{ {
/* Clause failed -- try finding a logical-or clause */ /* Clause failed -- try finding a logical-or clause */

View file

@ -36,7 +36,7 @@ enum tag_type { tag_artist = 0, tag_album, tag_genre, tag_title,
/* Real tags end here, count them. */ /* Real tags end here, count them. */
TAG_COUNT, TAG_COUNT,
/* Virtual tags */ /* Virtual tags */
tag_virt_length_min, tag_virt_length_sec, tag_virt_basename, tag_virt_length_min, tag_virt_length_sec,
tag_virt_playtime_min, tag_virt_playtime_sec, tag_virt_playtime_min, tag_virt_playtime_sec,
tag_virt_entryage, tag_virt_autoscore }; tag_virt_entryage, tag_virt_autoscore };
@ -106,7 +106,7 @@ enum tag_type { tag_artist = 0, tag_album, tag_genre, tag_title,
(1LU << tag_tracknumber) | (1LU << tag_length) | (1LU << tag_bitrate) | \ (1LU << tag_tracknumber) | (1LU << tag_length) | (1LU << tag_bitrate) | \
(1LU << tag_playcount) | (1LU << tag_rating) | (1LU << tag_playtime) | \ (1LU << tag_playcount) | (1LU << tag_rating) | (1LU << tag_playtime) | \
(1LU << tag_lastplayed) | (1LU << tag_commitid) | (1LU << tag_mtime) | \ (1LU << tag_lastplayed) | (1LU << tag_commitid) | (1LU << tag_mtime) | \
(1LU << tag_lastoffset) | \ (1LU << tag_lastoffset) | (1LU << tag_virt_basename) | \
(1LU << tag_virt_length_min) | (1LU << tag_virt_length_sec) | \ (1LU << tag_virt_length_min) | (1LU << tag_virt_length_sec) | \
(1LU << tag_virt_playtime_min) | (1LU << tag_virt_playtime_sec) | \ (1LU << tag_virt_playtime_min) | (1LU << tag_virt_playtime_sec) | \
(1LU << tag_virt_entryage) | (1LU << tag_virt_autoscore)) (1LU << tag_virt_entryage) | (1LU << tag_virt_autoscore))

View file

@ -238,6 +238,7 @@ static int get_tag(int *tag)
{"Ps", tag_virt_playtime_sec}, {"Ps", tag_virt_playtime_sec},
{"title", tag_title}, {"title", tag_title},
{"filename", tag_filename}, {"filename", tag_filename},
{"basename", tag_virt_basename},
{"tracknum", tag_tracknumber}, {"tracknum", tag_tracknumber},
{"discnum", tag_discnumber}, {"discnum", tag_discnumber},
{"year", tag_year}, {"year", tag_year},