# Possible support to DirectoryIterator to be include_path aware via flag

- Thread: https://externals.io/message/46460
- Original archive: https://news-web.php.net/php.internals/46460
- Started by Guilherme Blanco on 2009-12-17T16:19:04+00:00
- Messages: 4
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #46460 — Guilherme Blanco — 2009-12-17T16:19:04+00:00

URL: https://externals.io/message/46460#46460

Hi guys,

With new namespace inclusions, standards group releasing a common
autoloader, etc, I'm felling the necessity of something.

Basically, I'm suggesting to follow the same way SplFileInfo does,
with a few difference.
Currently, SplFileInfo is include_path aware with anything defined.

DirectoryIterator is not include_path aware, and trying something like:

$dirIterator = new DirectoryIterator('Zend/Form/Element');

Will raise an UnexpectedValueException. Looking at constructor
prototype, we have this:

DirectoryIterator::__construct(string $path);

My suggesting is to add support to include_path just like fopen
already have, which is through a flag. So the prototype would be:

DirectoryIterator::__construct(string $path [, bool $include_path = false]);

Possibly including the getRealPath() method too.

So, what do you think? I'm just suggesting to make the support
compatible between files and directories.
Also, I have a special need for this feature.


Cheers,

-- 
Guilherme Blanco - Web Developer
CBC - Certified Bindows Consultant
Cell Phone: +55 (16) 9215-8480
MSN: guilhermeblanco@hotmail.com
URL: http://blog.bisna.com
São Paulo - SP/Brazil

---

## #46461 — Stanislav Malyshev — 2009-12-17T18:55:29+00:00

URL: https://externals.io/message/46460#46461 · In reply to: #46460

Hi!

> My suggesting is to add support to include_path just like fopen
> already have, which is through a flag. So the prototype would be:
>
> DirectoryIterator::__construct(string $path [, bool $include_path = false]);

Maybe instead of adding this parameter one-by-one to every function 
doing anything with files, we should have just one function that 
resolves path against include path? `stream_resolve_include_path()` sounds 
like a good candidate, not sure if it also does directories.
-- 
Stanislav Malyshev, Zend Software Architect
stas@zend.com   http://www.zend.com/
(408)253-8829   MSN: stas@zend.com

---

## #46463 — Guilherme Blanco — 2009-12-17T20:31:54+00:00

URL: https://externals.io/message/46460#46463 · In reply to: #46461

Yes, but `stream_resolve_include_path()` works only for files and also
it's PHP6 only. =(


> Hi!
>
> > […]
>
> Maybe instead of adding this parameter one-by-one to every function doing
> anything with files, we should have just one function that resolves path
> against include path? `stream_resolve_include_path()` sounds like a good
> candidate, not sure if it also does directories.
> --
> Stanislav Malyshev, Zend Software Architect
> stas@zend.com   http://www.zend.com/
> (408)253-8829   MSN: stas@zend.com
>
> --
> 
> 
>
>



-- 
Guilherme Blanco - Web Developer
CBC - Certified Bindows Consultant
Cell Phone: +55 (16) 9215-8480
MSN: guilhermeblanco@hotmail.com
URL: http://blog.bisna.com
São Paulo - SP/Brazil

---

## #46464 — johannes@php.net — 2009-12-17T23:51:31+00:00

URL: https://externals.io/message/46460#46464 · In reply to: #46463

> Yes, but `stream_resolve_include_path()` works only for files and also
> it's PHP6 only. =(

Should be quite simple to merge to other branches if anybody really
cares. Doesn't look like anybody cared from the time 5.3 came up until
at least now :-)

In general I don't like this include path magic as it's not really clear
what happens, with the include_path flag set the iterator for instance
might iterate over all matching directories in all include paths.

johannes

> 
> > […]
> 
> 
> 
> -- 
> Guilherme Blanco - Web Developer
> CBC - Certified Bindows Consultant
> Cell Phone: +55 (16) 9215-8480
> MSN: guilhermeblanco@hotmail.com
> URL: http://blog.bisna.com
> São Paulo - SP/Brazil
