Return a match if a pattern matches relative_path, providing a pre-computed basename_pos which is the
starting position of the basename of relative_path. is_dir is true if relative_path is a directory.
case specifies whether cases should be folded during matching or not.