From eab7e747788bd633104019ab82bc75b384a95eff Mon Sep 17 00:00:00 2001 From: Michael Hohmuth Date: Sun, 31 Jul 2011 16:26:35 +0000 Subject: 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 --- apps/tagcache.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'apps/tagcache.c') diff --git a/apps/tagcache.c b/apps/tagcache.c index 089bba1..e841d8e 100644 --- a/apps/tagcache.c +++ b/apps/tagcache.c @@ -871,6 +871,10 @@ static long check_virtual_tags(int tag, int idx_id, - find_tag(tag_commitid, idx_id, idx) - 1; break; + case tag_virt_basename: + tag = tag_filename; /* return filename; caller handles basename */ + /* FALLTHRU */ + default: 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 (clause->tag == tag_filename) + if (clause->tag == tag_filename + || clause->tag == tag_virt_basename) { 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)) { - 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); ecread_tagfile_entry(fd, &tfe); 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)) { /* Clause failed -- try finding a logical-or clause */ -- cgit v1.1