vfs: check userland buffers before reading them.
[haiku.git] / src / bin / filteredquery / FilteredQuery.h
blobe95d3a0d5523eef844f1537a94ff05236f78833a
1 #ifndef __FILTEREDQUERY_H
2 #define __FILTEREDQUERY_H
4 #include <Query.h>
6 #include "ObjectList.h"
8 typedef bool (*filter_function)(const entry_ref *ref, void *arg);
10 struct filter_pair {
11 filter_function filter;
12 void *args;
14 filter_pair(filter_function function, void *arguments)
16 filter = function;
17 args = arguments;
22 class TFilteredQuery : public BQuery {
23 public:
24 TFilteredQuery();
26 // BQuery doesn't have a copy constructor. We supply
27 // this method to workaround this problem
28 TFilteredQuery(const BQuery &query);
29 TFilteredQuery(const TFilteredQuery &query);
30 virtual ~TFilteredQuery();
32 bool AddFilter(filter_function function, void *arg);
33 void RemoveFilter(filter_function function);
35 virtual status_t GetNextRef(entry_ref *ref);
36 virtual status_t GetNextEntry(BEntry *entry, bool traverse = false);
37 virtual int32 GetNextDirents(dirent *buf, size_t length, int32 count = INT_MAX);
39 status_t Clear();
41 private:
42 BObjectList<filter_pair> fFilters;
45 #endif //__FILTEREDQUERY_H