Function CheckWildcardPathMatch#

Function Documentation#

inline bool CheckWildcardPathMatch(const std::filesystem::path &rpathRel, const std::string &rssPattern)#

Check for a match between a relative path and a pattern containing zero or more wildcards.

Check for the relative path matching a relative path-pattern possibly containing wildcard patterns. The following rules to patterns apply:

  • Definition of path-part: paths are split into directories optionally followed by a filename. As separator ‘/’ is used.

  • A directory name of ‘.’ has a special meaning directing to the current directory.

  • A directory name of ‘..’ has a special meaning directing to a directory one up.

  • Directory and file name can be separated with dots (for example “dir1.2/file0.bin”).

  • Within the path-part following zero or more characters, use ‘?’ for any one character that might fit. The ‘?’ might be followed by zero or more characters and wildcards.

  • Within the path-part following zero or more characters, use ‘*’ for zero or more character until the next character or separator. The ‘*’ might be followed by zero or more characters and wildcards.

  • It should be possible to use a directory as a pattern (without the file name) - then all the files of the directory are matching (but not the files of the subdirectories).

  • If the path-part equals ‘**’, zero or more path-parts can be skipped to fit the rest of the path. This rule doesn’t apply if the part-part equals ‘*’ and is the last part in the path. Examples are:

  • ”subdir1” - directory only; all files within the directory (but not any sub-directories) match.

  • ”subdir1” - all files within the directory match.

  • ”subdir2/file2?.*n” - all files located in subdir2 starting with “file2” followed by a single digit or character with the extension ending with “n” match.

  • ”subdir?_*” - all files from a directory starting with the name “subdir” followed by a single digit or character, followed with a “_” and zero or more characters.

  • ”**\/file*.bin” - all files starting with the name “file” followed by zero or more characters and the extension “.bin” in this and any subdirectory.

Parameters:
  • rpathRel[in] Reference to the relative path to check for a match.

  • rssPattern[in] Reference to the string containing the pattern to match.

Returns:

Returns whether the path matches.