package path_glob

  1. Overview
  2. Docs
Globbing file paths

Install

Dune Dependency

Authors

Maintainers

Sources

path_glob-0.3.tgz
sha256=332dae23b700fa050d1fd6e4f3d2e24b8dd1db2c8ea4f76c54e2e54851c9d226
sha512=205b0bbdf0d36b21e978603e4df264a0b185f3c1e3a20764fb254368977977d076a5b9c53b88110b721651d43a782e45742b14891412460101fb5fa8a5986173

doc/index.html

Path_glob: checking glob patterns on paths.

Path_glob is a small library to match strings (in particular filesystem paths) against glob-style patterns, or boolean combinations of patterns.

open Path_glob

(* paths starting with 'foo/' or ending with a '.ml' extension *)
let globber = Glob.parse "<foo/**> or <**/*.ml> or <foo bar/*.txt> or <\\$special/*.txt>"

let () =
    assert (Glob.eval globber "foo/blah" = true);
    assert (Glob.eval globber "bar/blah/baz" = false);
    assert (Glob.eval globber "bar/blah/baz.ml" = true);
    assert (Glob.eval globber "foo bar/baz.txt" = true);
    assert (Glob.eval globber "$special/baz.txt" = true);

Path_glob was extracted from the ocamlbuild sources. In ocamlbuild it is used in _tags file, to apply tags on files based on a globbing pattern, for example:

<**/*.ml> or <**/*.mli>: warn_L, warn_R, warn_Z, annot
"src/discard_printf.ml": rectypes
<**/*.byte> or <**/*.native> or <**/*.top>: use_unix
<**/*.cmx>: for-pack(Ocamlbuild_pack)
<**/{ocamlbuild_{pack,unix_plugin,plugin,executor},ppcache}{,.p}.cmx>: -for-pack(Ocamlbuild_pack)

Modules:

  • Path_glob.Glob: the main entry point of the module, which includes a documentation of the glob pattern syntax.
  • Path_glob.Ast: abstract syntax trees for glob patterns <...>.
  • Path_glob.Formula: boolean combinations of glob patterns (true, false, and, or, not).
  • Path_glob.Lexer: a lexer function for glob formulas.
OCaml

Innovation. Community. Security.