1 |
|
|
/** |
2 |
|
|
* This file is part of the CernVM File System. |
3 |
|
|
*/ |
4 |
|
|
|
5 |
|
|
#ifndef CVMFS_PATH_FILTERS_RELAXED_PATH_FILTER_H_ |
6 |
|
|
#define CVMFS_PATH_FILTERS_RELAXED_PATH_FILTER_H_ |
7 |
|
|
|
8 |
|
|
#include <string> |
9 |
|
|
|
10 |
|
|
#include "path_filters/dirtab.h" |
11 |
|
|
|
12 |
|
|
namespace catalog { |
13 |
|
|
|
14 |
|
|
/** |
15 |
|
|
* A RelaxedPathFilter works similar to a Dirtab but it matches more generously: |
16 |
|
|
* in addition to the actual paths it represents, all parent paths are matched. |
17 |
|
|
* Sub paths of given paths are matched, too. In contrast to Dirtab, trailing |
18 |
|
|
* slashes of path specifications are ignored. |
19 |
|
|
* |
20 |
|
|
* For instance: |
21 |
|
|
* /software/releases |
22 |
|
|
* ! /software/releases/misc |
23 |
|
|
* ! /software/releases/experimental/misc |
24 |
|
|
* |
25 |
|
|
* Results in the following positive matches |
26 |
|
|
* /software, /software/releases, /software/releases/v1, |
27 |
|
|
* /software/releases/experimental |
28 |
|
|
* and in the following non-matches |
29 |
|
|
* /software/apps, /software/releases/misc, /software/releases/misc/external, |
30 |
|
|
* /software/releases/experimental/misc, |
31 |
|
|
* /software/releases/experimental/misc/foo |
32 |
|
|
* |
33 |
|
|
* It is used by cvmfs_preload as a specification of a partial subtree for |
34 |
|
|
* synchronization with a cache directory. |
35 |
|
|
*/ |
36 |
✗✗✓ |
11 |
class RelaxedPathFilter : public Dirtab { |
37 |
|
|
public: |
38 |
|
|
static RelaxedPathFilter* Create(const std::string &dirtab_path); |
39 |
|
|
virtual bool Parse(const std::string &dirtab); |
40 |
|
|
virtual bool Parse(FILE *dirtab_file); |
41 |
|
|
virtual bool IsMatching(const std::string &path) const; |
42 |
|
|
virtual bool IsOpposing(const std::string &path) const; |
43 |
|
|
|
44 |
|
|
protected: |
45 |
|
|
virtual bool ParsePathspec(const std::string &pathspec_str, bool negation); |
46 |
|
|
|
47 |
|
|
private: |
48 |
|
|
/** |
49 |
|
|
* Represents the entries in the provided dirtab file without parent paths. |
50 |
|
|
* It is necessary to match sub paths against the provided dirtab. |
51 |
|
|
*/ |
52 |
|
|
Dirtab exact_dirtab_; |
53 |
|
|
}; |
54 |
|
|
|
55 |
|
|
} // namespace catalog |
56 |
|
|
|
57 |
|
|
#endif // CVMFS_PATH_FILTERS_RELAXED_PATH_FILTER_H_ |