Code

filelist: added filelist_find_directory()
authorMax Kellermann <max@duempel.org>
Fri, 3 Oct 2008 09:53:55 +0000 (11:53 +0200)
committerMax Kellermann <max@duempel.org>
Fri, 3 Oct 2008 09:53:55 +0000 (11:53 +0200)
The function filelist_find_directory() will be useful for the
following patch.

src/filelist.c
src/filelist.h

index 46137cd3b00ca6f15df939b6e4003eea0b2d18f5..415eec4021a6038c5def9f96a1d05b6871e52f5f 100644 (file)
@@ -139,3 +139,22 @@ filelist_find_song(struct filelist *fl, const struct mpd_song *song)
 
        return NULL;
 }
+
+int
+filelist_find_directory(struct filelist *filelist, const char *name)
+{
+       guint i;
+
+       assert(name != NULL);
+
+       for (i = 0; i < filelist_length(filelist); ++i) {
+               struct filelist_entry *entry = filelist_get(filelist, i);
+               mpd_InfoEntity *entity  = entry->entity;
+
+               if (entity && entity->type == MPD_INFO_ENTITY_TYPE_DIRECTORY &&
+                   strcmp(entity->info.directory->path, name) == 0)
+                       return i;
+       }
+
+       return -1;
+}
index 85e551fc3619943461b2e59659ae2ffcf7ddd8d5..d7d4dff888ba107bbbccb76506ab86d355b216db 100644 (file)
@@ -76,4 +76,7 @@ filelist_sort(struct filelist *filelist, GCompareFunc compare_func);
 struct filelist_entry *
 filelist_find_song(struct filelist *flist, const struct mpd_song *song);
 
+int
+filelist_find_directory(struct filelist *filelist, const char *name);
+
 #endif