Glob::glob() and Glob.match()

A general discussion forum.
Posts: 3
Joined: 11 Apr 2008, 18:53

Glob::glob() and Glob.match()

Postby aspooner » 14 Mar 2009, 04:29

I'm trying to use Glob. However, there is an inconsistency between match() and glob(). Example:

If I have a file /tmp/testdir/testdir/bob,

Glob::glob("/tmp/testdir/test*") returns only /tmp/testdir/testdir/.

Glob g("/tmp/testdir/test*");
g.match("/tmp/testdir/testdir/bob") returns true.

I'd like the "*" in Glob::glob("/tmp/testdir/test*") to match path separaters, like g.match() does. Is this a bug?

Glancing at the code, it looks to me like

Glob.cpp:89 pattern.makeDirectory(); // to simplify pattern handling later on

appends a "/", which might cause "*" to only match in that directory.

Any help is appreciated,

Posts: 3
Joined: 11 Apr 2008, 18:53

Re: Glob::glob() and Glob.match()

Postby aspooner » 16 Mar 2009, 15:30

Ok, it's really this line:
if (p.depth() < pathPattern.depth() - 1)
in collect() that stops it from matching past the same level as the pattern.

I just wrote my own collect() function that recurses directories while they match() pattern.

This would be easier if collect() was virtual...

I guess what I could really use is a collect() that handles "**" as "recursively match directories" like ruby's Dir.glob(). Then I could modify my pattern to be:



Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 2 guests