Open xmichaelx opened 2 years ago
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
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?
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.
It would be useful if methods
Glob.Files
andGlob.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?