Thread overview
dirEntries with ** (recursive) globbing
Nov 11, 2013
Timothee Cour
Nov 12, 2013
Jacob Carlborg
Nov 13, 2013
Timothee Cour
Nov 13, 2013
Jacob Carlborg
Apr 02, 2017
timotheecour
Nov 13, 2013
Timothee Cour
Apr 03, 2017
Jesse Phillips
November 11, 2013
Is there any plan to add recursive globs to dirEntries?

use case:

auto entries=dirEntry("foo/**/bar/*suffix/*.{d,di}", spanMode,
followSymlink)
will match for example:
foo/a/b/bar/somethingsuffix/file.d

Note, ** will match any number (>=0) of directories, whereas a single * is
non-recursive

(as found in some good shells and IIRC, later versions of python, etc).

note, in this case, spanMode could only be breadth or depth, not shallow as the glob fully specifies depth.

I have partially working code (it doesn't handle {} but does handle * and **), however it's not the most efficient, so was wondering.


November 12, 2013
On 2013-11-12 00:45, Timothee Cour wrote:
> Is there any plan to add recursive globs to dirEntries?
>
> use case:
>
> auto entries=dirEntry("foo/**/bar/*suffix/*.{d,di}", spanMode,
> followSymlink)
> will match for example:
> foo/a/b/bar/somethingsuffix/file.d
>
> Note, ** will match any number (>=0) of directories, whereas a single *
> is non-recursive
>
> (as found in some good shells and IIRC, later versions of python, etc).
>
> note, in this case, spanMode could only be breadth or depth, not shallow
> as the glob fully specifies depth.
>
> I have partially working code (it doesn't handle {} but does handle *
> and **), however it's not the most efficient, so was wondering.

There's an overload of "dirEntries" that takes a path and a pattern. It says the pattern is matched using std.path.globMatch. "globMatch" matches "*" recursively.

-- 
/Jacob Carlborg
November 13, 2013
alas, no, I posted on exactly this some times ago:
glob is non-recursive in D:
http://forum.dlang.org/post/mailman.2367.1382320537.1719.digitalmars-d-learn@puremagic.com

Furthermore, it would be very inefficient to filter out results given by recursive dirEntries that match a glob pattern in general case (I can give examples if needed)




On Mon, Nov 11, 2013 at 11:28 PM, Jacob Carlborg <doob@me.com> wrote:

> On 2013-11-12 00:45, Timothee Cour wrote:
>
>> Is there any plan to add recursive globs to dirEntries?
>>
>> use case:
>>
>> auto entries=dirEntry("foo/**/bar/*suffix/*.{d,di}", spanMode,
>> followSymlink)
>> will match for example:
>> foo/a/b/bar/somethingsuffix/file.d
>>
>> Note, ** will match any number (>=0) of directories, whereas a single *
>> is non-recursive
>>
>> (as found in some good shells and IIRC, later versions of python, etc).
>>
>> note, in this case, spanMode could only be breadth or depth, not shallow as the glob fully specifies depth.
>>
>> I have partially working code (it doesn't handle {} but does handle * and **), however it's not the most efficient, so was wondering.
>>
>
> There's an overload of "dirEntries" that takes a path and a pattern. It says the pattern is matched using std.path.globMatch. "globMatch" matches "*" recursively.
>
> --
> /Jacob Carlborg
>


November 13, 2013
and this is further compounded by http://d.puremagic.com/issues/show_bug.cgi?id=11501 : dirEntries fails with "Failed to stat file" when encountering broken symlinks which i posted couple days ago


On Wed, Nov 13, 2013 at 4:20 AM, Timothee Cour <thelastmammoth@gmail.com>wrote:

> alas, no, I posted on exactly this some times ago:
> glob is non-recursive in D:
>
> http://forum.dlang.org/post/mailman.2367.1382320537.1719.digitalmars-d-learn@puremagic.com
>
> Furthermore, it would be very inefficient to filter out results given by recursive dirEntries that match a glob pattern in general case (I can give examples if needed)
>
>
>
>
> On Mon, Nov 11, 2013 at 11:28 PM, Jacob Carlborg <doob@me.com> wrote:
>
>> On 2013-11-12 00:45, Timothee Cour wrote:
>>
>>> Is there any plan to add recursive globs to dirEntries?
>>>
>>> use case:
>>>
>>> auto entries=dirEntry("foo/**/bar/*suffix/*.{d,di}", spanMode,
>>> followSymlink)
>>> will match for example:
>>> foo/a/b/bar/somethingsuffix/file.d
>>>
>>> Note, ** will match any number (>=0) of directories, whereas a single *
>>> is non-recursive
>>>
>>> (as found in some good shells and IIRC, later versions of python, etc).
>>>
>>> note, in this case, spanMode could only be breadth or depth, not shallow as the glob fully specifies depth.
>>>
>>> I have partially working code (it doesn't handle {} but does handle * and **), however it's not the most efficient, so was wondering.
>>>
>>
>> There's an overload of "dirEntries" that takes a path and a pattern. It says the pattern is matched using std.path.globMatch. "globMatch" matches "*" recursively.
>>
>> --
>> /Jacob Carlborg
>>
>
>


November 13, 2013
On 2013-11-13 13:20, Timothee Cour wrote:
> alas, no, I posted on exactly this some times ago:
> glob is non-recursive in D:
> http://forum.dlang.org/post/mailman.2367.1382320537.1719.digitalmars-d-learn@puremagic.com

Hmm, right, my bad.

-- 
/Jacob Carlborg
April 02, 2017
On Wednesday, 13 November 2013 at 13:34:37 UTC, Jacob Carlborg wrote:
> On 2013-11-13 13:20, Timothee Cour wrote:
>> alas, no, I posted on exactly this some times ago:
>> glob is non-recursive in D:
>> http://forum.dlang.org/post/mailman.2367.1382320537.1719.digitalmars-d-learn@puremagic.com
>
> Hmm, right, my bad.

ping on this.
April 03, 2017
On Monday, 11 November 2013 at 23:53:26 UTC, Timothee Cour wrote:
> Is there any plan to add recursive globs to dirEntries?

I don't think there is any plan. These have traditionally been shell features, but probably useful in a programming library also.