Skip to content

Enhancement: Add bool glob::match function #28

Open
@shakfu

Description

@shakfu

While this library works as advertized.. (Thanks!), may I suggest to add a couple of bool functions which match a glob pattern or a vector of glob patterns against a given std::filesystem::path:

This is useful when one already has a pre-existing recursive filesystem iterator or algorithm.

This is a 'naive' implementation based on the pre-existing fnmatch function:

    bool match(fs::path name, std::vector<std::string> patterns)
    {
        for (auto& p : patterns) {
            if (glob::fnmatch(name, p)) {
                return true;
            }
        }
        return false;
    }
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions