Uni/Fnmatch#

Interface to the fnmatch C function.

Info

To use declarations from this page, include the <essence/uni/fnmatch.hpp> header.

They are found within the essence::uni namespace.

enum class fnm : i32#

Options passed to fnmatch.

enumerator fnm::none = 0#
enumerator fnm::pathname = FNM_PATHNAME#
enumerator fnm::period = FNM_PERIOD#
enumerator fnm::no_escape = FNM_NOESCAPE#
enumerator fnm::case_fold = FNM_CASEFOLD#
enumerator fnm::extended_match = FNM_EXTMATCH#
enumerator fnm::leading_dir = FNM_LEADING_DIR#
bool fnmatch(const std::string &pattern, const std::string &name, fnm flags)#

Return true if pattern would match the file name.

Parameters pattern and name may also be const char*.

Example

#include <essence/io.hpp>
#include <essence/uni/dirent.hpp>
#include <essence/uni/fnmatch.hpp>

using namespace essence;

std::string pat { "*.cpp" };

auto entries = uni::scandir("src");

// print all entries in `src` who match the "*.cpp" glob pattern.
for (const auto& entry: entries)
{
   if (uni::fnmatch(pat, entry))
      io::printn("match: {}", entry);
}