Skip to content

Latest commit

 

History

History
72 lines (49 loc) · 1.89 KB

File metadata and controls

72 lines (49 loc) · 1.89 KB

Aster - Fast C++ Globbing

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.

Installation

CMake

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>

Headers

Since Aster is header-only, all files within /include can be used directly.

Examples

Glob Matching

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 match

Glob Walking

auto options = Aster::Options( /** initial directory */ );
auto markdown = Aster::Walker("**/*.md"); // match ".md" files
for (const auto& entry : markdown.iterate(options)) { ... }

Glob 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.
};

Credits

This library is based on the pattern-matching algorithm in oxc-project/fast-glob which is derived from on devongovett/glob-match.

License

This software is released under the terms of the MIT license.