filefilter.h 1.5 KB

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