summaryrefslogtreecommitdiff
path: root/src/mp3_vnops.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mp3_vnops.c')
-rwxr-xr-xsrc/mp3_vnops.c98
1 files changed, 2 insertions, 96 deletions
diff --git a/src/mp3_vnops.c b/src/mp3_vnops.c
index b04f0dc..8348064 100755
--- a/src/mp3_vnops.c
+++ b/src/mp3_vnops.c
@@ -8,25 +8,13 @@
#include <sys/types.h>
#include <dirent.h>
#include <fuse.h>
+#include <sys/param.h>
#include <id3.h>
-
-#define MAXPATHLEN 100000
+#include <mp3fs.h>
char *musicpath = "/home/lulf/dev/mp3fs/music";
-typedef void traverse_fn_t(char *, void *);
-
-void traverse_hierarchy(char *, traverse_fn_t, void *);
-traverse_fn_t mp3_artist;
-/*
- * Data passed to traverse function pointers.'
- */
-struct filler_data {
- void *buf;
- fuse_fill_dir_t filler;
-};
-
static int mp3_getattr (const char *path, struct stat *stbuf)
{
memset (stbuf, 0, sizeof (struct stat));
@@ -82,88 +70,6 @@ call_lol(char *path)
printf("Path %s\n", path);
}
-/*
- * Traverse a hierarchy given a directory path. Perform fileoperations on the
- * files in the directory giving data as arguments, as well as recursing on
- * sub-directories.
- */
-void
-traverse_hierarchy(char *dirpath, traverse_fn_t fileop, void *data)
-{
- DIR *dirp;
- struct dirent *dp;
- char filepath[MAXPATHLEN];
- struct stat st;
- struct filler_data *fd;
-
- fd = data;
- dirp = opendir(dirpath);
- if (dirp == NULL) {
- fd->filler(fd->buf, "lolerr", NULL, 0);
- return;
- }
-
- /* Loop through all files. */
- while ((dp = readdir(dirp)) != NULL) {
- if (!strcmp(dp->d_name, ".") ||
- !strcmp(dp->d_name, ".."))
- continue;
-
- snprintf(filepath, sizeof(filepath), "%s/%s",
- dirpath, dp->d_name);
- if (stat(filepath, &st) < 0)
- err(1, "error doing stat on %s", filepath);
- /* Recurse if it's a directory. */
- if (st.st_mode & S_IFDIR) {
- traverse_hierarchy(filepath, fileop, data);
- continue;
- }
- /* If it's a regular file, perform the operation. */
- if (st.st_mode & S_IFREG) {
- fileop(filepath, data);
- }
- }
- closedir(dirp);
-}
-
-
-
-/*
- * Retrieve artist name given a file, and put in a buffer with a passed filler
- * function
- */
-void
-mp3_artist(char *filepath, void *data)
-{
- struct filler_data *fd;
- ID3Tag *tag;
- ID3Frame *artist;
- ID3Field *field;
- fuse_fill_dir_t filler;
- void *buf;
- char name[MAXPATHLEN];
-
- /* Retrieve the filler function and pointers. */
- fd = (struct filler_data *)data;
- filler = fd->filler;
- buf = fd->buf;
-
- /* Get the tag. */
- tag = ID3Tag_New();
- ID3Tag_Link(tag, filepath);
- artist = ID3Tag_FindFrameWithID(tag, ID3FID_LEADARTIST);
- if (artist == NULL)
- return;
- field = ID3Frame_GetField(artist, ID3FN_TEXT);
- if (field == NULL)
- return;
- ID3Field_GetASCII(field, name, ID3Field_Size(field));
- /* XXX: doesn't show up... why? */
- filler(buf, name, NULL, 0);
- ID3Tag_Delete(tag);
- return;
-}
-
static int mp3_open (const char *path, struct fuse_file_info *fi)
{
if (strcmp (path, "/Artists") == 0)