]> git.decadent.org.uk Git - dak.git/blob - tools/dsync-0.0/libdsync/filefilter.h
Merge mainline
[dak.git] / tools / dsync-0.0 / libdsync / filefilter.h
1 // -*- mode: cpp; mode: fold -*-
2 // Description                                                          /*{{{*/
3 // $Id: filefilter.h,v 1.2 1998/12/30 05:36:41 jgg Exp $
4 /* ######################################################################
5    
6    File Filter - Regular Expression maching filter
7    
8    This implements an ordered include/exclude filter list that can be used
9    to filter filenames.
10
11    Pattern matching is done identically to rsync, the key points are:
12     - Patterns containing / are matched against the whole path, otherwise
13       only the file name is used.
14     - Patterns that end in a / only match directories
15     - Wildcards supported by fnmatch (?*[)
16    
17    ##################################################################### */
18                                                                         /*}}}*/
19 #ifndef DSYNC_FILEFILTER
20 #define DSYNC_FILEFILTER
21
22 #ifdef __GNUG__
23 #pragma interface "dsync/filefilter.h"
24 #endif 
25
26 #include <string>
27 #include <dsync/configuration.h>
28
29 class dsFileFilter
30 {
31    protected:
32    
33    struct Item
34    {
35       enum {Include, Exclude} Type;
36       string Pattern;
37       
38       // Various flags.
39       enum {MatchAll = (1<<0), MatchPath = (1<<1)};
40       unsigned long Flags;
41       
42       Item *Next;
43
44       bool Test(const char *Directory,const char *File);
45    };
46    Item *List;
47    
48    public:
49
50    // Members to see if the filter hits or misses
51    bool Test(const char *Directory,const char *File);
52    
53    // Load the filter from a configuration space
54    bool LoadFilter(Configuration::Item const *Root);
55       
56    dsFileFilter();
57    ~dsFileFilter();
58 };
59
60 #endif