diff options
author | 2010-08-05 12:19:58 +0200 | |
---|---|---|
committer | 2010-08-05 12:19:58 +0200 | |
commit | 8acd1b573753efa1e16547637922d4d1ae422b2e (patch) | |
tree | b052d91ac93a11b0c4dac0d0aa63f2c59b5e7e17 /playlist.c | |
parent | 0300cff32a065303b2687cf151ea4807bdb48929 (diff) |
added new %d and %D conversions to pl_format_title, for directory path
Diffstat (limited to 'playlist.c')
-rw-r--r-- | playlist.c | 47 |
1 files changed, 47 insertions, 0 deletions
@@ -2444,6 +2444,7 @@ pl_format_title_int (const char *escape_chars, playItem_t *it, int idx, char *s, char elp[50]; char fno[50]; char tags[200]; + char dirname[PATH_MAX]; const char *duration = NULL; const char *elapsed = NULL; @@ -2604,6 +2605,52 @@ pl_format_title_int (const char *escape_chars, playItem_t *it, int idx, char *s, } meta = tags; } + else if (*fmt == 'd') { + // directory + const char *end = it->fname + strlen (it->fname) - 1; + while (end > it->fname && (*end) != '/') { + end--; + } + if (*end != '/') { + meta = ""; // got relative path without folder (should not happen) + } + else { + const char *start = end; + start--; + while (start > it->fname && (*start != '/')) { + start--; + } + + if (*start == '/') { + start++; + } + + // copy + int len = end-start; + len = min (len, sizeof (dirname)-1); + strncpy (dirname, start, len); + dirname[len] = 0; + meta = dirname; + } + } + else if (*fmt == 'D') { + // directory with path + const char *end = it->fname + strlen (it->fname) - 1; + while (end > it->fname && (*end) != '/') { + end--; + } + if (*end != '/') { + meta = ""; // got relative path without folder (should not happen) + } + else { + // copy + int len = end - it->fname; + len = min (len, sizeof (dirname)-1); + strncpy (dirname, it->fname, len); + dirname[len] = 0; + meta = dirname; + } + } else { *s++ = *fmt; n--; |