Coder Social home page Coder Social logo

filepattern's Introduction

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.

filepattern's People

Contributors

andreasabel avatar eborden avatar felixonmars avatar ndmitchell avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

filepattern's Issues

Symlink treated as directory

This is

Reproducer in filepattern-0.1.2:

$ mkdir dir
$ mkdir dir/a
$ mkdir dir/b
$ touch dir/a/file
$ ln -s dir/a/file dir/b/file
$ tree
.
└── dir
    ├── a
    │   └── file
    └── b
        └── file -> dir/a/file
$ ghci
GHCi, version 9.2.3: https://www.haskell.org/ghc/  :? for help
ghci> :m + System.FilePattern.Directory
ghci> getDirectoryFiles "." ["**"]
*** Exception: ./dir/b/file/: getDirectoryContents:openDirStream: does not exist (No such file or directory)

Add function to delete recursively

Should have one that deletes recursively as normal, and one that deletes through read-only files too.

Need to think what i do about directories.

Required for Shake

Add Module based alternative

Seemingly matching on module names, with conversion to/from . Separators. Perhaps I just need an alternative module where you pick the split character? Or work on lists of strings rather than / separated ones?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.