Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement: Add bool glob::match function #28

Open
shakfu opened this issue Mar 27, 2024 · 0 comments
Open

Enhancement: Add bool glob::match function #28

shakfu opened this issue Mar 27, 2024 · 0 comments

Comments

@shakfu
Copy link

shakfu commented Mar 27, 2024

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;
    }
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant