fswatch  1.14.0
Static Public Member Functions | Public Attributes | List of all members
fsw::monitor_filter Struct Reference

Path filters used to accept or reject file change events. More...

#include <filter.hpp>

Static Public Member Functions

static std::vector< monitor_filterread_from_file (const std::string &path, void(*err_handler)(std::string)=nullptr)
 Load filters from the specified file. More...
 

Public Attributes

std::string text
 Regular expression used to match the paths. More...
 
fsw_filter_type type
 Filter type.
 
bool case_sensitive
 Flag indicating whether monitor_filter::text is a case sensitive regular expression.
 
bool extended
 Flag indicating whether monitor_filter::text is an extended regular expression. More...
 

Detailed Description

Path filters used to accept or reject file change events.

A path filter is a regular expression used to accept or reject file change events based on the value of their path. A filter has the following characteristics:

Further information about how filtering works in libfswatch can be found in Path Filtering.

Member Function Documentation

◆ read_from_file()

vector< monitor_filter > fsw::monitor_filter::read_from_file ( const std::string &  path,
void(*)(std::string)  err_handler = nullptr 
)
static

Load filters from the specified file.

Filters can be loaded from a text file containing one filter per line. A filter has the following structure:

  • It is validated by the following regular expression: ^([+-])([ei]*) (.+)$
  • The first character is the filter type: + if it is an inclusion filter, - if it is an exclusion filter.
  • An optional list of flags:
    • e if it is an extended regular expression.
    • i if it is a case insensitive regular expression.
  • A space.
  • The filter regular expression text.

Parsing errors are notified through an optional error handler. The valid filters are returned in a vector.

Parameters
pathThe path of the file to read filters from.
err_handlerAn optional error handler.
Returns
A vector containing the valid filters.
Exceptions
invalid_argumentIf the specified path cannot be opened.

Member Data Documentation

◆ extended

bool fsw::monitor_filter::extended

Flag indicating whether monitor_filter::text is an extended regular expression.

Further information about extended regular expressions can be found here:

http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap09.html#tag_09_04

◆ text

std::string fsw::monitor_filter::text

Regular expression used to match the paths.

Further information about regular expressions can be found here:

http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap09.html


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