talira

Match file paths against Unix shell style patterns in Rust

open sourceMIT OR Apache-2.0free

glob is the Rust Project's crate for matching file paths against Unix shell style patterns. Its glob and glob_with functions walk the filesystem for every path a pattern matches, like libc's glob, and its Pattern type checks single paths, like fnmatch. It's written entirely in Rust rather than calling libc, so it behaves the same on Windows. Patterns support ?, *, recursive ** and [...] character classes, with options for case sensitivity and literal separators and leading dots.

Problems it solves

  • find all files matching a pattern like **/*.jpg from my Rust program
  • check whether a path matches a shell wildcard pattern in Rust
  • expand glob patterns in a Rust CLI the same way on Windows and Linux

Features

  • find every file matching a pattern, like libc glob
  • check a single path against a pattern, like fnmatch
  • recursive ** matching across directories
  • [...] and [!...] character classes
  • case-insensitive and literal-separator match options
  • pure Rust, the same behaviour on Windows

Alternatives

The same job

These do what glob does.

  1. walkdir Walk a directory tree recursively in Rust, efficiently and on every platform

Compare glob with the top 3