www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - dirEntries with ** (recursive) globbing

reply Timothee Cour <thelastmammoth gmail.com> writes:
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.
Nov 11 2013
parent reply Jacob Carlborg <doob me.com> writes:
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
Nov 11 2013
next sibling parent reply Timothee Cour <thelastmammoth gmail.com> writes:
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
Nov 13 2013
parent Jacob Carlborg <doob me.com> writes:
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
Nov 13 2013
prev sibling parent Timothee Cour <thelastmammoth gmail.com> writes:
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
Nov 13 2013