Giter Site home page Giter Site logo

glob.cs's Introduction

Glob.cs

Version Build status codecov.io netstandard2.0 net461

Single-source-file path globbing for .NET (netstandard2.0 and net461).

Features

  • Choose case sensitivity
  • Optionally match only directories
  • Injectable file system implementation for easy testing (uses System.IO.Abstractions)
  • Can cancel long running match
  • Throw or continue on file system errors
  • Optionally log errors to supplied log implementation
  • Lazy tree traversal
  • Option to limit depth of ** expansion

Syntax

  • ? matches a single character
  • * matches zero or more characters
  • ** matches zero or more recursive directories, e.g. a\**\x matches a\x, a\b\x, a\b\c\x, etc.
  • [...] matches a set of characters, syntax is the same as character groups in Regex.
  • {group1,group2,...} matches any of the pattern groups. Groups can contain groups and patterns, e.g. {a\b,{c,d}*}.

Usage

Install the NuGet package Glob.cs. Then:

var dlls = Glob.Expand(@"c:\windows\system32\**\*.dll");

glob.cs's People

Contributors

dependabot-preview[bot] avatar dependabot[bot] avatar jtone123 avatar mganss avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

glob.cs's Issues

Support a depth limit

It would be nice if Glob.cs could support a depth limit so that it doesn't go on infinitely. The Cancel method is nice but seems to require another thread in order to issue that cancellation.

Support CancellationToken for cancelling

Another thing I thought about was allowing Expand to take in a CancellationToken. This would allow for the use of:

https://docs.microsoft.com/en-us/dotnet/api/system.threading.cancellationtokensource.cancelafter?view=netframework-4.7.2

and other cancellation scenarios. From what I could tell, today you have to start the Expand in one thread and cancel it in another manually. Using the CancellationToken seems like a C#-y way of cancelling a currently expanding Glob.

Please update the NuGet package

Could you please publish an updated release to NuGet.org?
The latest NuGet package of Glob.cs - 5.1.766 - is based on a severely outdated version of System.IO.Abstractions and is difficult to integrate with current package versions.

Expand returns empty when an existing directory is specified and dirOnly is false

I'm not sure if this is the intended behaviour.

To reproduce:
ExpandNames("/tmp/abcd") where /tmp/abcd exists and is a directory.

dirOnly == true mean only directories will be returned, so dirOnly = false should include files and directories.

Maybe if can be fixed by changing line 192:
fsi = dirOnly || fileSystem.Directory.Exists(path) ? (IFileSystemInfo)fileSystem.DirectoryInfo.FromDirectoryName(path) : fileSystem.FileInfo.FromFileName(path);

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.