filepattern: File path glob-like matching

[ bsd3, development, filepath, library ] [ Propose Tags ] [ Report a vulnerability ]

A library for matching files using patterns such as "src/**/*.png" for all .png files recursively under the src directory. Features:

  • All matching is O(n). Most functions precompute some information given only one argument.

  • See System.FilePattern and ?== simple matching and semantics.

  • Use match and substitute to extract suitable strings from the * and ** matches, and substitute them back into other patterns.

  • Use step and matchMany to perform bulk matching of many patterns against many paths simultaneously.

  • Use System.FilePattern.Directory to perform optimised directory traverals using patterns.

Originally taken from the Shake library.


[Skip to Readme]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1, 0.1.1, 0.1.2, 0.1.3
Change log CHANGES.txt
Dependencies base (>=4 && <5), directory, extra (>=1.6.2), filepath [details]
Tested with ghc ==9.0, ghc ==8.10, ghc ==8.8, ghc ==8.6, ghc ==8.4, ghc ==8.2, ghc ==8.0
License BSD-3-Clause
Copyright Neil Mitchell 2011-2022
Author Neil Mitchell <ndmitchell@gmail.com>, Evan Rutledge Borden <evan@evan-borden.com>
Maintainer Neil Mitchell <ndmitchell@gmail.com>
Category Development, FilePath
Home page https://github.com/ndmitchell/filepattern#readme
Bug tracker https://github.com/ndmitchell/filepattern/issues
Source repo head: git clone https://github.com/ndmitchell/filepattern.git
Uploaded by NeilMitchell at 2022-08-21T18:06:19Z
Distributions Arch:0.1.3, Debian:0.1.2, Fedora:0.1.3, LTSHaskell:0.1.3, NixOS:0.1.3, Stackage:0.1.3, openSUSE:0.1.3
Reverse Dependencies 18 direct, 127 indirect [details]
Downloads 21510 total (187 in the last 30 days)
Rating 2.0 (votes: 1) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2022-08-21 [all 1 reports]

Readme for filepattern-0.1.3

[back to package description]

FilePattern Hackage version Stackage version Build status

A library for matching files using patterns such as src/**/*.png for all .png files recursively under the src directory. There are two special forms:

  • * matches part of a path component, excluding any separators.
  • ** as a path component matches an arbitrary number of path components.

Some examples:

  • test.c matches test.c and nothing else.
  • *.c matches all .c files in the current directory, so file.c matches, but file.h and dir/file.c don't.
  • **/*.c matches all .c files anywhere on the filesystem, so file.c, dir/file.c, dir1/dir2/file.c and /path/to/file.c all match, but file.h and dir/file.h don't.
  • dir/*/* matches all files one level below dir, so dir/one/file.c and dir/two/file.h match, but file.c, one/dir/file.c, dir/file.h and dir/one/two/file.c don't.

More complete semantics are given in the documentation for the matching function ?==.

Features

  • All matching is O(n). Most functions precompute some information given only one argument. There are also functions to provide bulk matching of many patterns against many paths simultaneously, see step and matchMany.
  • You can obtain the parts that matched the * and ** special forms using match, and substitute them into other patterns using substitute.
  • You can search for files using a minimal number of IO operations, using the System.FilePattern.Directory module.
  • Another Haskell file pattern matching library is Glob, which aims to be closer to the POSIX glob() function, with forms such as *, ?, **/ (somewhat different to the filepattern equivalent) and [:alpha:]. A complete guide is in the documentation. Compared to filepattern, the Glob library is closer to a regular expression library - definitely more powerful, potentially harder to use.
  • The shake library has contained a FilePattern type since the beginning. This library evolved from that code, with significant improvements.
  • The semantics are heavily inspired by VS Code, Git and the NPM package Glob.