aboutsummaryrefslogtreecommitdiffstats
path: root/src/directory.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-04-01 18:41:37 +0200
committerMax Kellermann <max@duempel.org>2009-04-01 18:41:37 +0200
commit7f38c3fc78f7dd3c542cdb73bcd45bfe2208a5a8 (patch)
tree9f3c8de9b5f3ef58960268aab0c2cf8d9e6e0591 /src/directory.c
parent36ec2edacfbf17b5308312ad5617117685004174 (diff)
downloadmpd-7f38c3fc78f7dd3c542cdb73bcd45bfe2208a5a8.tar.gz
mpd-7f38c3fc78f7dd3c542cdb73bcd45bfe2208a5a8.tar.xz
mpd-7f38c3fc78f7dd3c542cdb73bcd45bfe2208a5a8.zip
directory: added directory_lookup_song()
Moved code from db_get_song().
Diffstat (limited to '')
-rw-r--r--src/directory.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/directory.c b/src/directory.c
index ef2cd1c2c..85c24fd04 100644
--- a/src/directory.c
+++ b/src/directory.c
@@ -114,6 +114,36 @@ directory_lookup_directory(struct directory *directory, const char *uri)
return found;
}
+struct song *
+directory_lookup_song(struct directory *directory, const char *uri)
+{
+ char *duplicated, *base;
+ struct song *song;
+
+ assert(directory != NULL);
+ assert(uri != NULL);
+
+ duplicated = g_strdup(uri);
+ base = strrchr(duplicated, '/');
+
+ if (base != NULL) {
+ *base++ = 0;
+ directory = directory_lookup_directory(directory, duplicated);
+ if (directory == NULL) {
+ g_free(duplicated);
+ return NULL;
+ }
+ } else
+ base = duplicated;
+
+ song = songvec_find(&directory->songs, base);
+ assert(song == NULL || song->parent == directory);
+
+ g_free(duplicated);
+ return song;
+
+}
+
void
directory_sort(struct directory *directory)
{