diff options
Diffstat (limited to 'src/SongFilter.cxx')
-rw-r--r-- | src/SongFilter.cxx | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/src/SongFilter.cxx b/src/SongFilter.cxx index 49c966b6f..0cf2b1b2f 100644 --- a/src/SongFilter.cxx +++ b/src/SongFilter.cxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2013 The Music Player Daemon Project + * Copyright (C) 2003-2014 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify @@ -20,6 +20,7 @@ #include "config.h" #include "SongFilter.hxx" #include "Song.hxx" +#include "DetachedSong.hxx" #include "tag/Tag.hxx" #include "util/ASCII.hxx" #include "util/UriUtil.hxx" @@ -151,6 +152,18 @@ SongFilter::Item::Match(const Song &song) const return song.tag != NULL && Match(*song.tag); } +bool +SongFilter::Item::Match(const DetachedSong &song) const +{ + if (tag == LOCATE_TAG_BASE_TYPE) + return uri_is_child_or_same(value.c_str(), song.GetURI()); + + if (tag == LOCATE_TAG_FILE_TYPE) + return StringMatch(song.GetURI()); + + return Match(song.GetTag()); +} + SongFilter::SongFilter(unsigned tag, const char *value, bool fold_case) { items.push_back(Item(tag, value, fold_case)); @@ -203,6 +216,16 @@ SongFilter::Match(const Song &song) const return true; } +bool +SongFilter::Match(const DetachedSong &song) const +{ + for (const auto &i : items) + if (!i.Match(song)) + return false; + + return true; +} + std::string SongFilter::GetBase() const { |