diff options
author | 2010-12-05 16:07:59 +0100 | |
---|---|---|
committer | 2010-12-05 16:07:59 +0100 | |
commit | 92aa0e95f1d2f006acc8ebaf4c4451a854d2d0ec (patch) | |
tree | 4115b70c71b13a2b7686e64e83e07c6f768512f9 /plugins/gtkui/callbacks.c | |
parent | 3629cd4e9959093cd38fc630604d04dce93eda6c (diff) |
added support for filetype prefix-test (for uade2 mod.title files); some code cleanup
Diffstat (limited to 'plugins/gtkui/callbacks.c')
-rw-r--r-- | plugins/gtkui/callbacks.c | 37 |
1 files changed, 24 insertions, 13 deletions
diff --git a/plugins/gtkui/callbacks.c b/plugins/gtkui/callbacks.c index 8cd520bc..e7f6f77c 100644 --- a/plugins/gtkui/callbacks.c +++ b/plugins/gtkui/callbacks.c @@ -58,26 +58,37 @@ extern DB_functions_t *deadbeef; // defined in gtkui.c static gboolean file_filter_func (const GtkFileFilterInfo *filter_info, gpointer data) { // get ext - const char *p = filter_info->filename + strlen (filter_info->filename)-1; - while (p >= filter_info->filename) { - if (*p == '.') { - break; - } - p--; - } - if (*p != '.') { + const char *p = strrchr (filter_info->filename, '.'); + if (!p) { return FALSE; } p++; + + // get beginning of fname + const char *fn = strrchr (filter_info->filename, '/'); + if (!fn) { + fn = filter_info->filename; + } + else { + fn++; + } + + DB_decoder_t **codecs = deadbeef->plug_get_decoder_list (); for (int i = 0; codecs[i]; i++) { if (codecs[i]->exts && codecs[i]->insert) { const char **exts = codecs[i]->exts; - if (exts) { - for (int e = 0; exts[e]; e++) { - if (!strcasecmp (exts[e], p)) { - return TRUE; - } + for (int e = 0; exts[e]; e++) { + if (!strcasecmp (exts[e], p)) { + return TRUE; + } + } + } + if (codecs[i]->prefixes && codecs[i]->insert) { + const char **prefixes = codecs[i]->prefixes; + for (int e = 0; prefixes[e]; e++) { + if (!strncasecmp (prefixes[e], fn, strlen(prefixes[e])) && *(fn + strlen (prefixes[e])) == '.') { + return TRUE; } } } |