diff options
author | Max Kellermann <max@duempel.org> | 2013-01-03 10:01:34 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2013-01-03 10:02:43 +0100 |
commit | 93f0bb8307ea26cc9ef96cf368110e8f6f0caead (patch) | |
tree | dfaa8e6be0fe0f4868acf34018b39d6bf9427f09 /src/ExcludeList.cxx | |
parent | 47fc08bffe94d33c88caafd084fa24e31e902798 (diff) | |
download | mpd-93f0bb8307ea26cc9ef96cf368110e8f6f0caead.tar.gz mpd-93f0bb8307ea26cc9ef96cf368110e8f6f0caead.tar.xz mpd-93f0bb8307ea26cc9ef96cf368110e8f6f0caead.zip |
ExcludeList: convert to a class
Diffstat (limited to 'src/ExcludeList.cxx')
-rw-r--r-- | src/ExcludeList.cxx | 30 |
1 files changed, 8 insertions, 22 deletions
diff --git a/src/ExcludeList.cxx b/src/ExcludeList.cxx index e71a99203..4beb7afc3 100644 --- a/src/ExcludeList.cxx +++ b/src/ExcludeList.cxx @@ -34,8 +34,8 @@ extern "C" { #include <stdio.h> #include <errno.h> -GSList * -exclude_list_load(const char *path_fs) +bool +ExcludeList::LoadFile(const char *path_fs) { assert(path_fs != NULL); @@ -48,10 +48,9 @@ exclude_list_load(const char *path_fs) g_free(path_utf8); } - return NULL; + return false; } - GSList *list = NULL; char line[1024]; while (fgets(line, sizeof(line), file) != NULL) { char *p = strchr(line, '#'); @@ -60,37 +59,24 @@ exclude_list_load(const char *path_fs) p = g_strstrip(line); if (*p != 0) - list = g_slist_prepend(list, g_pattern_spec_new(p)); + patterns.emplace_front(p); } fclose(file); - return list; -} - -void -exclude_list_free(GSList *list) -{ - while (list != NULL) { - GPatternSpec *pattern = (GPatternSpec *)list->data; - g_pattern_spec_free(pattern); - list = g_slist_remove(list, list->data); - } + return true; } bool -exclude_list_check(GSList *list, const char *name_fs) +ExcludeList::Check(const char *name_fs) const { assert(name_fs != NULL); /* XXX include full path name in check */ - for (; list != NULL; list = list->next) { - GPatternSpec *pattern = (GPatternSpec *)list->data; - - if (g_pattern_match_string(pattern, name_fs)) + for (const auto &i : patterns) + if (i.Check(name_fs)) return true; - } return false; } |