2 Copyright (C) 2000-2007 Paul Davis
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 #ifndef __libmisc_pathscanner_h__
21 #define __libmisc_pathscanner_h__
34 vector<string *> *operator() (const string &dirpath,
35 bool (*filter)(const string &, void *arg),
37 bool match_fullpath = true,
38 bool return_fullpath = true,
40 return run_scan (dirpath,
41 (bool (PathScanner::*)(const string &)) 0,
49 vector<string *> *operator() (const string &dirpath,
51 bool match_fullpath = true,
52 bool return_fullpath = true,
56 string *find_first (const string &dirpath,
58 bool match_fullpath = true,
59 bool return_fullpath = true);
61 string *find_first (const string &dirpath,
62 bool (*filter)(const string &, void *),
64 bool match_fullpath = true,
65 bool return_fullpath = true);
68 regex_t compiled_pattern;
70 bool regexp_filter (const string &str) {
71 return regexec (&compiled_pattern, str.c_str(), 0, 0, 0) == 0;
74 vector<string *> *run_scan (const string &dirpath,
75 bool (PathScanner::*mfilter) (const string &),
76 bool (*filter)(const string &, void *),
85 #endif // __libmisc_pathscanner_h__