+static
+bool
+regexp_filter (const string& str, void *arg)
+{
+ regex_t* pattern = (regex_t*)arg;
+ return regexec (pattern, str.c_str(), 0, 0, 0) == 0;
+}
+
+void
+find_files_matching_regex (vector<string>& result,
+ const Searchpath& paths,
+ const std::string& regexp,
+ bool recurse)
+{
+ int err;
+ char msg[256];
+ regex_t compiled_pattern;
+
+ if ((err = regcomp (&compiled_pattern, regexp.c_str(),
+ REG_EXTENDED|REG_NOSUB))) {
+
+ regerror (err, &compiled_pattern,
+ msg, sizeof (msg));
+
+ error << "Cannot compile soundfile regexp for use ("
+ << msg
+ << ")"
+ << endmsg;
+
+ return;
+ }
+
+ DEBUG_TRACE (DEBUG::FileUtils,
+ string_compose("Matching files using regexp: %1\n", regexp));
+
+ find_files_matching_filter (result, paths,
+ regexp_filter, &compiled_pattern,
+ true, true, recurse);
+
+ regfree (&compiled_pattern);
+}
+
+void
+find_paths_matching_filter (vector<string>& result,
+ const Searchpath& paths,
+ bool (*filter)(const string &, void *),
+ void *arg,
+ bool pass_fullpath, bool return_fullpath,
+ bool recurse)
+{
+ run_functor_for_paths (result, paths, filter, arg, false, pass_fullpath, return_fullpath, recurse);
+}
+
+void
+find_files_matching_filter (vector<string>& result,
+ const Searchpath& paths,
+ bool (*filter)(const string &, void *),
+ void *arg,
+ bool pass_fullpath, bool return_fullpath,
+ bool recurse)
+{
+ run_functor_for_paths (result, paths, filter, arg, true, pass_fullpath, return_fullpath, recurse);
+}
+