Re: Question about the difference between `glob` and `GlobIterator` behaviour
| From: | lists at cmsws dot com | Date: | Wed, 23 Mar 2016 22:12:07 +0000 |
| Subject: | Re: Question about the difference between `glob` and `GlobIterator` behaviour | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-325486@lists.php.net to get a copy of this message | ||
On 2016-03-23 02:28, Stéphane HULARD wrote:
Hello ! I’m currently working on the Hoa Project (http://hoa-project.net) about aBy no means do I pretend to have any insight to the internals of PHP, but if I were to take a guess, I would say that the functionality of the glob was initially modelled after the glob'ing ability found in most all *nix cli tools from years past.globbehaviour integration: https://github.com/hoaproject/File/pull/22 We found that there are some difference between theglobfunction and theGlobIteratorobject. 1.globThis 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.GlobIteratorThis 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 complicated. 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 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 www.chstudio.fr -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php