CernVM-FS  2.12.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
catalog::Dirtab Class Reference

#include <dirtab.h>

Inheritance diagram for catalog::Dirtab:

Classes

struct  Rule
 

Public Types

typedef std::vector< RuleRules
 

Public Member Functions

 Dirtab ()
 
virtual ~Dirtab ()
 
virtual bool Parse (const std::string &dirtab)
 
virtual bool Parse (FILE *dirtab_file)
 
virtual bool IsMatching (const std::string &path) const
 
virtual bool IsOpposing (const std::string &path) const
 
const Rulespositive_rules () const
 
const Rulesnegative_rules () const
 
size_t RuleCount () const
 
size_t NegativeRuleCount () const
 
size_t PositiveRuleCount () const
 
bool IsValid () const
 

Static Public Member Functions

static DirtabCreate (const std::string &dirtab_path)
 

Static Public Attributes

static const char kCommentMarker = '#'
 
static const char kNegationMarker = '!'
 

Protected Member Functions

bool Open (const std::string &dirtab_path)
 
bool ParseLine (const std::string &line)
 
virtual bool ParsePathspec (const std::string &pathspec_str, bool negation)
 
void AddRule (const Rule &rule)
 

Private Member Functions

void SkipWhitespace (const std::string::const_iterator &end, std::string::const_iterator *itr) const
 
bool CheckRuleValidity () const
 

Private Attributes

bool valid_
 
Rules positive_rules_
 
Rules negative_rules_
 

Detailed Description

A Dirtab is handling the parsing and processing of the .cvmfsdirtab file. The .cvmfsdirtab contains a list of Pathspecs that define where CernVM-FS should automatically create nested catalogs. Furthermore it can contain neg- ative rules to omit the automatic creation of nested catalogs in certain directories.

Example (adding a space in front of * - silence compiler warning):

this is a .cvmfsdirtab comment

/software/releases/ * /conditions_data/runs/ *

ignore repository directories

! *.svn ! *.git

This .cvmfsdirtab file would generate nested catalogs in all directories directly inside /software/releases/ and /conditions_data/runs/ like: /software/releases/2.1.1-2/.cvmfscatalog /software/releases/2.3.4-1/.cvmfscatalog /software/releases/3.0.0-5/.cvmfscatalog ... /conditions_data/runs/27.11.2014/.cvmfscatalog /conditions_data/runs/11.09.2013/.cvmfscatalog ...

Note: This class does not take care of the actual creation of nested catalogs but wraps the parsing and matching of the .cvmfsdirtab file and given path strings. See: swissknife_sync.{h,cc} or t_dirtab.cc for the usage of this class.

Definition at line 51 of file dirtab.h.

Member Typedef Documentation

typedef std::vector<Rule> catalog::Dirtab::Rules

Definition at line 68 of file dirtab.h.

Constructor & Destructor Documentation

catalog::Dirtab::Dirtab ( )

Creates an empty Dirtab (mainly for testing purposes)

Definition at line 18 of file dirtab.cc.

Referenced by Create().

Here is the caller graph for this function:

virtual catalog::Dirtab::~Dirtab ( )
inlinevirtual

Definition at line 75 of file dirtab.h.

Member Function Documentation

void catalog::Dirtab::AddRule ( const Rule rule)
protected

Definition at line 115 of file dirtab.cc.

Referenced by ParsePathspec().

Here is the caller graph for this function:

bool catalog::Dirtab::CheckRuleValidity ( ) const
private

Definition at line 124 of file dirtab.cc.

Referenced by Parse().

Here is the call graph for this function:

Here is the caller graph for this function:

static Dirtab* catalog::Dirtab::Create ( const std::string &  dirtab_path)
inlinestatic

Returns an already filled Dirtab

Parameters
dirtab_pathpath of the dirtab file that will be used to fill the Dirtab object
Returns
the already filled Dirtab

Definition at line 84 of file dirtab.h.

Referenced by swissknife::CommandApplyDirtab::Main().

Here is the call graph for this function:

Here is the caller graph for this function:

bool catalog::Dirtab::IsMatching ( const std::string &  path) const
virtual

Matches a given path string against this Dirtab. The path is considered a match if it matches against (at least) one positive rule and is not matched by any negative rule.

Parameters
paththe path string to be matched against this Dirtab
Returns
true if path string is matching this Dirtab

Reimplemented in catalog::RelaxedPathFilter.

Definition at line 144 of file dirtab.cc.

Referenced by catalog::RelaxedPathFilter::IsMatching().

Here is the call graph for this function:

Here is the caller graph for this function:

bool catalog::Dirtab::IsOpposing ( const std::string &  path) const
virtual

Matches a given path string against all negative rules in this Dirtab. This bypasses the check for positive rules, thus a path string can be opposed by this Dirtab while it would also not match any positive rule.

Parameters
paththe path string to be checked for opposition of this Dirtab
Returns
true if (at least) one negative rule matches

Reimplemented in catalog::RelaxedPathFilter.

Definition at line 161 of file dirtab.cc.

Referenced by swissknife::CommandApplyDirtab::FilterCandidatesFromGlobResult(), IsMatching(), and catalog::RelaxedPathFilter::IsOpposing().

Here is the call graph for this function:

Here is the caller graph for this function:

bool catalog::Dirtab::IsValid ( ) const
inline

Definition at line 127 of file dirtab.h.

Referenced by swissknife::CommandPull::Main(), and swissknife::CommandApplyDirtab::Main().

Here is the caller graph for this function:

const Rules& catalog::Dirtab::negative_rules ( ) const
inline

Definition at line 122 of file dirtab.h.

size_t catalog::Dirtab::NegativeRuleCount ( ) const
inline

Definition at line 125 of file dirtab.h.

Referenced by RuleCount().

Here is the caller graph for this function:

bool catalog::Dirtab::Open ( const std::string &  dirtab_path)
protected

Fill a Dirtab from a given .cvmfsdirtab file path.

Definition at line 21 of file dirtab.cc.

Referenced by catalog::RelaxedPathFilter::Create(), and Create().

Here is the call graph for this function:

Here is the caller graph for this function:

bool catalog::Dirtab::Parse ( const std::string &  dirtab)
virtual

Parses the content of a .cvmfsdirtab file. This is called by the filepath- constructor or can be used on an empty Dirtab for testing purposes and in inherited classes.

Parameters
dirtaba string containing the full content of a .cvmfsdirtab file
Returns
true on successful parsing

Reimplemented in catalog::RelaxedPathFilter.

Definition at line 43 of file dirtab.cc.

Referenced by Open(), and catalog::RelaxedPathFilter::Parse().

Here is the call graph for this function:

Here is the caller graph for this function:

bool catalog::Dirtab::Parse ( FILE *  dirtab_file)
virtual

Reimplemented in catalog::RelaxedPathFilter.

Definition at line 59 of file dirtab.cc.

Here is the call graph for this function:

bool catalog::Dirtab::ParseLine ( const std::string &  line)
protected

Definition at line 72 of file dirtab.cc.

Referenced by Parse().

Here is the call graph for this function:

Here is the caller graph for this function:

bool catalog::Dirtab::ParsePathspec ( const std::string &  pathspec_str,
bool  negation 
)
protectedvirtual

Reimplemented in catalog::RelaxedPathFilter.

Definition at line 95 of file dirtab.cc.

Referenced by ParseLine(), and catalog::RelaxedPathFilter::ParsePathspec().

Here is the call graph for this function:

Here is the caller graph for this function:

const Rules& catalog::Dirtab::positive_rules ( ) const
inline

Definition at line 121 of file dirtab.h.

Referenced by swissknife::CommandApplyDirtab::DetermineNestedCatalogCandidates().

Here is the caller graph for this function:

size_t catalog::Dirtab::PositiveRuleCount ( ) const
inline

Definition at line 126 of file dirtab.h.

Referenced by RuleCount().

Here is the caller graph for this function:

size_t catalog::Dirtab::RuleCount ( ) const
inline

Definition at line 124 of file dirtab.h.

Referenced by swissknife::CommandApplyDirtab::Main().

Here is the call graph for this function:

Here is the caller graph for this function:

void catalog::Dirtab::SkipWhitespace ( const std::string::const_iterator &  end,
std::string::const_iterator *  itr 
) const
inlineprivate

Definition at line 139 of file dirtab.h.

Referenced by ParseLine().

Here is the caller graph for this function:

Member Data Documentation

const char catalog::Dirtab::kCommentMarker = '#'
static

Definition at line 53 of file dirtab.h.

Referenced by ParseLine().

const char catalog::Dirtab::kNegationMarker = '!'
static

Definition at line 54 of file dirtab.h.

Referenced by ParseLine().

Rules catalog::Dirtab::negative_rules_
private

Definition at line 150 of file dirtab.h.

Referenced by AddRule(), CheckRuleValidity(), IsOpposing(), negative_rules(), and NegativeRuleCount().

Rules catalog::Dirtab::positive_rules_
private

Definition at line 149 of file dirtab.h.

Referenced by AddRule(), CheckRuleValidity(), IsMatching(), positive_rules(), and PositiveRuleCount().

bool catalog::Dirtab::valid_
private

Definition at line 148 of file dirtab.h.

Referenced by IsValid(), Open(), and Parse().


The documentation for this class was generated from the following files: