Web lists-archives.com

[PHP] Question about the difference between `glob` and `GlobIterator` behaviour

Hello !

I’m currently working on the Hoa Project (http://hoa-project.net) about 
a `glob` behaviour integration: https://github.com/hoaproject/File/pull/22

We found that there are some difference between the `glob` function and the 
`GlobIterator` object.

1. `glob`
This function is able to scan only dirs with the GLOB_ONLYDIR constant and is also able 
to expand braces to match in a list of items with GLOB_BRACE.

Exemple with glob(‘/{a,b,c}/foo/bar’, GLOB_BRACE), it’ll search :
- /a/foo/bar
- /b/foo/bar
- /c/foo/bar

2. `GlobIterator`
This object has no options or constants to apply the same logic than GLOB_ONLYDIR and GLOB_BRACE.
It’s possible to combine different iterators and obtain the same result but it’s a lot more

Exemple with new GlobIterator(‘/{a,b,c}/foo/bar’), it’ll search :
- /{a,b,c}/foo/bar

Is there some reason about the differences in these two implementations ?
I found that the braces expansion is not part of the “official” glob pattern definition but
it’s definitively an awesome feature.

Thanks in advance for your attention.

Stéphane HULARD
Directeur technique & CEO
CH Studio - Collectif digital
2 rue d'Italie - 38490 Les Abrets
Phone: +33 (0)6 18 18 65 04

PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php