]> git.tuebingen.mpg.de Git - paraslash.git/blobdiff - afs_common.c
Remove old audio file selector code.
[paraslash.git] / afs_common.c
diff --git a/afs_common.c b/afs_common.c
deleted file mode 100644 (file)
index c45b3d9..0000000
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Copyright (C) 2005-2007 Andre Noll <maan@systemlinux.org>
- *
- * Licensed under the GPL v2. For licencing details see COPYING.
- */
-
-
-/** \file afs_common.c Functions common to all audio file selectors. */
-
-#include <sys/types.h>
-#include <dirent.h>
-
-
-#include "para.h"
-#include "error.h"
-#include "string.h"
-#include "fd.h"
-#include "server.cmdline.h"
-#include "afh.h"
-#include "afs.h"
-#include "server.h"
-#include "vss.h"
-#include <dirent.h> /* readdir() */
-#include <sys/stat.h> /* stat */
-#include <sys/types.h> /* mode_t */
-
-/**
- * Traverse the given directory recursively.
- *
- * \param dirname The directory to traverse.
- * \param f The function to call for each entry.
- *
- * For each regular file whose filename ends in .yyy, where yyy is a supported
- * audio format, the supplied function \a f is called.  The directory and
- * filename component of the regular file are passed to \a f.
- *
- * \return On success, 1 is returned. Otherwise, this function returns a
- * negative value which indicates the kind of the error.
- */
-int find_audio_files(const char *dirname, int (*f)(const char *, const char *))
-{
-       DIR *dir = NULL;
-       int ret, ret2, cwd_fd;
-       struct dirent *entry;
-
-       ret = para_opendir(dirname, &dir, &cwd_fd);
-       if (ret < 0)
-               return ret;
-       /* scan cwd recursively */
-       while ((entry = readdir(dir))) {
-               mode_t m;
-               char *tmp;
-               struct stat s;
-
-               if (!strcmp(entry->d_name, "."))
-                       continue;
-               if (!strcmp(entry->d_name, ".."))
-                       continue;
-               ret = -E_LSTAT;
-               if (lstat(entry->d_name, &s) == -1)
-                       continue;
-               m = s.st_mode;
-               if (!S_ISREG(m) && !S_ISDIR(m)) /* skip links, sockets, ... */
-                       continue;
-               if (S_ISREG(m)) { /* regular file */
-                       if (guess_audio_format(entry->d_name) < 0)
-                               continue;
-                       ret = f(dirname, entry->d_name);
-                       if (ret < 0)
-                               goto out;
-                       continue;
-               }
-               /* directory */
-               tmp = make_message("%s/%s", dirname, entry->d_name);
-               ret = find_audio_files(tmp, f);
-               free(tmp);
-               if (ret < 0)
-                       goto out;
-       }
-       ret = 1;
-out:
-       if (dir)
-               closedir(dir);
-       ret2 = fchdir(cwd_fd);
-       if (ret2 < 0 && ret >= 0)
-               ret = ret2;
-       close(cwd_fd);
-       if (ret < 0)
-               PARA_ERROR_LOG("%s\n", PARA_STRERROR(-ret));
-       return ret;
-}