Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for glob with parent directory included in single string #67

Open
xmichaelx opened this issue Oct 27, 2022 · 3 comments
Open

Support for glob with parent directory included in single string #67

xmichaelx opened this issue Oct 27, 2022 · 3 comments

Comments

@xmichaelx
Copy link

It would be useful if methods Glob.Files and Glob.Directories would support providing only one glob with parent directory concatenated like: C:/**/*.cs. This is something that is available in Python glob module.

Would it be possible to add such functionality or would you accept PR with such functionality?

@kthompson
Copy link
Owner

I just tested what you are describing in the UI and it appears to work. Maybe I am not following your specific use case? Can you provide a code sample that fails?

These are the parameters I used in the Glob tester UI:

Files:

C:\README.md
C:\ReleaseSteps.md
C:\src
C:\src\Glob
C:\src\Glob\AST
C:\src\Glob\AST\CharacterSet.cs
C:\src\Glob\AST\CharacterWildcard.cs
C:\src\Glob\AST\DirectorySegment.cs
C:\src\Glob\AST\DirectoryWildcard.cs
C:\src\Glob\AST\GlobNode.cs
C:\src\Glob\AST\GlobNodeType.cs
C:\src\Glob\AST\Identifier.cs
C:\src\Glob\AST\LiteralSet.cs
C:\src\Glob\AST\Root.cs
C:\src\Glob\AST\Segment.cs
C:\src\Glob\AST\StringWildcard.cs
C:\src\Glob\AST\SubSegment.cs
C:\src\Glob\AST\Tree.cs
C:\src\Glob\Glob.cs
C:\src\Glob\Glob.csproj
C:\src\Glob\Glob.Statics.cs
C:\src\Glob\GlobEvaluator.cs
C:\src\Glob\GlobExtensions.cs
C:\src\Glob\GlobOptions.cs
C:\src\Glob\GlobPatternException.cs
C:\src\Glob\Matcher.cs
C:\src\Glob\Parser.cs
C:\src\Glob\PathTraverser.cs
C:\src\Glob\PathTraverserEnumerable.cs
C:\src\Glob\Properties
C:\src\Glob\Properties\AssemblyInfo.cs
C:\src\Glob\TraverseOptions.cs
C:\test\Glob.Tests
C:\test\Glob.Tests\Glob.Tests.csproj
C:\test\Glob.Tests\GlobExtensionTests.cs
C:\test\Glob.Tests\GlobTests.cs
C:\test\Glob.Tests\MockFileSystemNode.cs
C:\test\Glob.Tests\MockTraverseOptions.cs
C:\test\Glob.Tests\MockTraverseOptionsTests.cs
C:\test\Glob.Tests\ParserTests.cs
C:\test\Glob.Tests\PathTests.cs
C:\test\Glob.Tests\PathTraverserTests.cs
C:\test\Glob.Tests\Properties
C:\test\Glob.Tests\Properties\AssemblyInfo.cs
C:\test\Glob.Tests\TestHelpers.cs

Expression: C:/src/**/*.cs

Results:

C:\src\Glob\AST\CharacterSet.cs
C:\src\Glob\AST\CharacterWildcard.cs
C:\src\Glob\AST\DirectorySegment.cs
C:\src\Glob\AST\DirectoryWildcard.cs
C:\src\Glob\AST\GlobNode.cs
C:\src\Glob\AST\GlobNodeType.cs
C:\src\Glob\AST\Identifier.cs
C:\src\Glob\AST\LiteralSet.cs
C:\src\Glob\AST\Root.cs
C:\src\Glob\AST\Segment.cs
C:\src\Glob\AST\StringWildcard.cs
C:\src\Glob\AST\SubSegment.cs
C:\src\Glob\AST\Tree.cs
C:\src\Glob\Glob.cs
C:\src\Glob\Glob.Statics.cs
C:\src\Glob\GlobEvaluator.cs
C:\src\Glob\GlobExtensions.cs
C:\src\Glob\GlobOptions.cs
C:\src\Glob\GlobPatternException.cs
C:\src\Glob\Matcher.cs
C:\src\Glob\Parser.cs
C:\src\Glob\PathTraverser.cs
C:\src\Glob\PathTraverserEnumerable.cs
C:\src\Glob\Properties\AssemblyInfo.cs
C:\src\Glob\TraverseOptions.cs

@xmichaelx
Copy link
Author

I mean the ability to call:

var files = Glob.Files("C:/**/*.cs");

instead of having to providing working directory separately:

var files = Glob.Files("C:/", "**/*.cs");

Is the former somehow possible?

@kthompson
Copy link
Owner

Oh yes I see now. I would probably try to parse the beginning of the pattern until a non-literal was found which would allow us to split the pattern into the constant part ie "c:/" and the pattern "**/*.cs" then use the existing overload to return the results.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants