From e2c8e28ef7ccda32fb32792b086c40144df2a916 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 3 Oct 2008 11:53:55 +0200 Subject: [PATCH] filelist: added filelist_find_directory() The function filelist_find_directory() will be useful for the following patch. --- src/filelist.c | 19 +++++++++++++++++++ src/filelist.h | 3 +++ 2 files changed, 22 insertions(+) diff --git a/src/filelist.c b/src/filelist.c index 46137cd..415eec4 100644 --- a/src/filelist.c +++ b/src/filelist.c @@ -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; +} diff --git a/src/filelist.h b/src/filelist.h index 85e551f..d7d4dff 100644 --- a/src/filelist.h +++ b/src/filelist.h @@ -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 -- 2.30.2