X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=db.c;h=8b06672606e50009004bd9dcf89625425295035b;hp=cb6f692a74cd136a712f961294b3b9fbc735729c;hb=501edee5b98e4133bb64f41f78ffec1cd6f91f7e;hpb=e921be422a216b87e3e6812f16b27c9a6927099d diff --git a/db.c b/db.c index cb6f692a..8b066726 100644 --- a/db.c +++ b/db.c @@ -28,29 +28,6 @@ #include "error.h" #include "string.h" -/* - * return 1 if name matches any supported audio format - */ -static int match_audio_file_name(char *name) -{ - int i,j, len = strlen(name); - - FOR_EACH_AUDIO_FORMAT(i) { - for (j = 0; afl[i].suffixes[j]; j++) { - const char *p = afl[i].suffixes[j]; - int plen = strlen(p); - if (len < plen + 1) - continue; - if (name[len - plen - 1] != '.') - continue; - if (strcasecmp(name + len - plen, p)) - continue; - return 1; - } - } - return 0; -} - /** * traverse the given directory recursively * @@ -98,14 +75,15 @@ int find_audio_files(const char *dirname, int (*f)(const char *, const char *)) continue; ret = -E_LSTAT; if (lstat(entry->d_name, &s) == -1) - goto out; + continue; m = s.st_mode; if (!S_ISREG(m) && !S_ISDIR(m)) /* skip links, sockets, ... */ continue; if (S_ISREG(m)) { /* regular file */ - if (!match_audio_file_name(entry->d_name)) + if (guess_audio_format(entry->d_name) < 0) continue; - if (f(dirname, entry->d_name) < 0) + ret = f(dirname, entry->d_name); + if (ret < 0) goto out; continue; }