X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=db.c;h=027dfda5933ca79fe9bebbe22c3a1d5e97f16a9c;hp=26f82d4a26d2ebbeb94be0f05a176df98692f4d9;hb=9847a8ce2fd749dda24017abc93cf0d1b25721b2;hpb=c8ca222a5dfee03f5ac8ccaf1d1bbf8a45f0874c diff --git a/db.c b/db.c index 26f82d4a..027dfda5 100644 --- a/db.c +++ b/db.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2006 Andre Noll + * Copyright (C) 2005-2007 Andre Noll * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -21,35 +21,13 @@ #include "server.cmdline.h" #include "server.h" -#include "afs.h" +#include "vss.h" #include /* readdir() */ #include /* stat */ #include /* mode_t */ #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, len = strlen(name); - const char *pattern[] = {SUPPORTED_AUDIO_FORMATS_ARRAY}; - - for (i = 0; pattern[i]; i++) { - const char *p = pattern[i]; - 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 * @@ -72,7 +50,7 @@ int find_audio_files(const char *dirname, int (*f)(const char *, const char *)) * is usually faster and more reliable than saving cwd in some buffer * and calling chdir() afterwards (see man 3 getcwd). */ - char cwd_fd = open(".", O_RDONLY); + int cwd_fd = open(".", O_RDONLY); struct stat s; int ret = -1; @@ -97,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; }