package path_glob

  1. Overview
  2. Docs
Globbing file paths

Install

Dune Dependency

Authors

Maintainers

Sources

path_glob-0.2.tbz
sha256=5e09a2148876b68ac8fb315679ba69b1e207ced55d91a3ea5b3046f917102a07
sha512=f55775c694e4b66acdfc9210cccc4af505ecbce3101b638495623d7f18a169e4c904e1b86c1c13ec3af9ae765acd6eedfa6cb7059a0c8a4a1aff375b7e9114ab

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>"

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);

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.