From c9b61f8df8a7cccb0768fd6ec6d1585ef3366743 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kjetil=20=C3=98rbekk?= Date: Tue, 12 Aug 2008 12:44:46 +0200 Subject: - Added Artist/* to mp3_open - Cleaned up the mp3_open code a bit --- src/mp3_vnops.c | 35 +++++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/src/mp3_vnops.c b/src/mp3_vnops.c index 8186c89..50913ee 100755 --- a/src/mp3_vnops.c +++ b/src/mp3_vnops.c @@ -144,7 +144,7 @@ static int mp3_open (const char *path, struct fuse_file_info *fi) { struct file_data fd; struct lookuphandle *lh; - char *title, *album; + char *title, *album, *artist; lh = NULL; fd.fd = -1; @@ -165,13 +165,6 @@ static int mp3_open (const char *path, struct fuse_file_info *fi) default: return (-ENOENT); } - mp3_lookup_finish(lh); - if (!fd.found) - return (-ENOENT); - if (fd.fd < 0) - return (-EIO); - close(fd.fd); - return (0); } else if (strncmp(path, "/Albums", 7) == 0) { switch (mp3_numtoken(path)) { case 3: @@ -192,6 +185,31 @@ static int mp3_open (const char *path, struct fuse_file_info *fi) default: return (-ENOENT); } + } else if (strncmp(path, "/Artists", 8) == 0) { + switch (mp3_numtoken(path)) { + case 4: + artist = mp3_gettoken(path, 2); + album = mp3_gettoken(path, 3); + title = mp3_gettoken(path, 4); + DEBUG("artist(%s) album(%s) title(%s)\n", artist, album, title); + if (!(artist && album && title)) { + break; + } + lh = mp3_lookup_start(0, &fd, mp3_lookup_open, + "SELECT filepath FROM song WHERE artistname LIKE ? AND " + "album LIKE ? AND title LIKE ?"); + if (lh == NULL) + return (-EIO); + mp3_lookup_insert(lh, artist, LIST_DATATYPE_STRING); + mp3_lookup_insert(lh, album, LIST_DATATYPE_STRING); + mp3_lookup_insert(lh, title, LIST_DATATYPE_STRING); + break; + default: + return (-ENOENT); + } + } + + if (lh) { mp3_lookup_finish(lh); if (!fd.found) return (-ENOENT); @@ -200,6 +218,7 @@ static int mp3_open (const char *path, struct fuse_file_info *fi) close(fd.fd); return (0); } + /* * 1. Have a lookup cache for names?. * Parse Genre, Album, Artist etc. -- cgit v1.2.3