#36996 [Opn->Bgs]: RecursiveDirectoryIterator
| From: | helly@php.net | Date: | Thu, 06 Apr 2006 19:15:37 +0000 |
| Subject: | #36996 [Opn->Bgs]: RecursiveDirectoryIterator | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-95390@lists.php.net to get a copy of this message | ||
ID: 36996
Updated by: helly@php.net
Reported By: reiv4x at free dot fr
-Status: Open
+Status: Bogus
Bug Type: SPL related
-Operating System: Gentoo Linux
+Operating System: *
-PHP Version: 5.1.2
+PHP Version: *
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
Before a call to rewind your $rdi is in an unpredictable state. After
rewind() '.' and '..' entries are filtered out. I suggest you look into
the examples in examples directory of ext/spl or online:
http://php.net/~helly
RTFM :-)
Previous Comments:
------------------------------------------------------------------------
[2006-04-06 15:00:35] reiv4x at free dot fr
Description:
------------
Hi!
I try this code but it's a strange result.
I don't receive same result for '.' directory.
Here is my directories structure :
# ll -R tmptest/
tmptest/:
total 12
-rw-r--r-- 1 apache apache 21 avr 6 15:56 tmpfile.txt
lrwxrwxrwx 1 apache apache 11 avr 6 15:56
tmplink.lnk -> tmpfile.txt
drwxr-xr-x 3 apache apache 4096 avr 6 15:56 tmpsubtest
drwxr-xr-x 2 apache apache 4096 avr 6 15:56 tmpsubtest2
tmptest/tmpsubtest:
total 4
drwxr-xr-x 2 apache apache 4096 avr 6 15:56
tmpsubsubtest
tmptest/tmpsubtest/tmpsubsubtest:
total 4
-rw-r--r-- 1 apache apache 21 avr 6 15:56 tmpfile.txt
tmptest/tmpsubtest2:
total 0
Reproduce code:
---------------
<?php
$rdi = new RecursiveDirectoryIterator('tmptest');
// -------- HERE CUT and PASTE X5 code bellow -------
echo '#############################<br />';
echo '__toString is = ['.$rdi.']<br />';
echo 'Current is = ['.$rdi->current().']<br />';
echo 'Key is = ['.$rdi->key().']<br />';
echo 'Valid is = ['.$rdi->valid().']<br />';
echo 'hasChildren is = ['.$rdi->hasChildren().']<br />';
$rdi->next();
// -------- HERE CUT and PASTE END -------
$rdi->rewind();
foreach ($rdi as $content) {
echo '++++++++++++++++++++++++++++++<br />';
echo '__toString is = ['.$rdi.']<br />';
echo 'Current is = ['.$rdi->current().']<br />';
echo 'Key is = ['.$rdi->key().']<br />';
echo 'Valid is = ['.$rdi->valid().']<br />';
echo 'hasChildren is = ['. $rdi->hasChildren().']<br />';
}
?>
Expected result:
----------------
#############################
__toString is = [tmpsubtest2]
Current is = [tmptest/tmpsubtest2]
Key is = [tmptest/tmpsubtest2]
Valid is = [1]
hasChildren is = [1]
#############################
__toString is = [tmpsubtest]
Current is = [tmptest/tmpsubtest]
Key is = [tmptest/tmpsubtest]
Valid is = [1]
hasChildren is = [1]
#############################
__toString is = [tmpfile.txt]
Current is = [tmptest/tmpfile.txt]
Key is = [tmptest/tmpfile.txt]
Valid is = [1]
hasChildren is = []
#############################
__toString is = [.tmpfilehidden.txt]
Current is = [tmptest/.tmpfilehidden.txt]
Key is = [tmptest/.tmpfilehidden.txt]
Valid is = [1]
hasChildren is = []
#############################
__toString is = [tmplink.lnk]
Current is = [tmptest/tmplink.lnk]
Key is = [tmptest/tmplink.lnk]
Valid is = [1]
hasChildren is = []
#############################
++++++++++++++++++++++++++++++
__toString is = [tmpsubtest2]
Current is = [tmptest/tmpsubtest2]
Key is = [tmptest/tmpsubtest2]
Valid is = [1]
hasChildren is = [1]
++++++++++++++++++++++++++++++
__toString is = [tmpsubtest]
Current is = [tmptest/tmpsubtest]
Key is = [tmptest/tmpsubtest]
Valid is = [1]
hasChildren is = [1]
++++++++++++++++++++++++++++++
__toString is = [tmpfile.txt]
Current is = [tmptest/tmpfile.txt]
Key is = [tmptest/tmpfile.txt]
Valid is = [1]
hasChildren is = []
++++++++++++++++++++++++++++++
__toString is = [.tmpfilehidden.txt]
Current is = [tmptest/.tmpfilehidden.txt]
Key is = [tmptest/.tmpfilehidden.txt]
Valid is = [1]
hasChildren is = []
++++++++++++++++++++++++++++++
__toString is = [tmplink.lnk]
Current is = [tmptest/tmplink.lnk]
Key is = [tmptest/tmplink.lnk]
Valid is = [1]
hasChildren is = []
Actual result:
--------------
In my result, these lines are add in first place.
I don't find '..' directory, only '.' and method
RecursiveDirectoryIterator::isDot() == True.
#############################
__toString is = [.]
Current is = [tmptest/.]
Key is = [tmptest/.]
Valid is = [1]
hasChildren is = []
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=36996&edit=1