Aster is an efficient, compact and robust cross-platform C++ globbing library. This library provides a fast baseline globbing function and an optimized walker for traversing the file-system through globs.
Add the following to your CMakeLists.txt:
include(FetchContent)
FetchContent_Declare(
aster
GIT_REPOSITORY https://github.com/rroessler/cpp.aster.git
GIT_TAG main # can replace this with a specific version
GIT_SHALLOW ON
)
FetchContent_MakeAvailable(aster)
target_link_libraries(${PROJECT_NAME} PRIVATE aster::aster)And then the library will be accessible via:
#include <aster/aster.hpp>Since Aster is header-only, all files within /include can be used directly.
auto glob = "some/**/path/**/n*[k-m]e?txt";
auto path = "some/small/or/large/path/to/a/needle.txt";
assert(Aster::Match::glob(glob, path)); // single matchauto options = Aster::Options( /** initial directory */ );
auto markdown = Aster::Walker("**/*.md"); // match ".md" files
for (const auto& entry : markdown.iterate(options)) { ... }struct Aster::Options {
bool files = true; // Allow matching files.
bool hidden = false; // Allow matching hidden entries.
bool symlinks = false; // Allow matching symlinks.
bool directories = false; // Allow matching directories.
std::string cwd = "..."; // The initial working directory.
};This library is based on the pattern-matching algorithm in oxc-project/fast-glob which is derived from on devongovett/glob-match.
This software is released under the terms of the MIT license.