php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #34615 RecursiveDirectoryIterator is not recursive
Submitted: 2005-09-23 15:30 UTC Modified: 2005-09-23 15:33 UTC
From: richard dot quadling at bandvulc dot co dot uk Assigned:
Status: Not a bug Package: SPL related
PHP Version: 5.0.5 OS: Windows
Private report: No CVE-ID: None
 [2005-09-23 15:30 UTC] richard dot quadling at bandvulc dot co dot uk
Description:
------------
Hopefully, my simple brain can explain this properly.

I want to use the RecursiveDirectoryIterator class.

Iterator = get "elements" from a "list", one at a time.
Directory = a "list" of files and directories (and links for those *ix bods).
Recursion = Repeat until complete on any "element" which contains a "list".

So, DirectoryIterator should return a list of files/directories for a single directory.

Which it does.

<?php
$objDI = new DirectoryIterator("C:/");
foreach($objDI as $key => $value)
	{
	echo "$key $value\n";
	}
?>

produces a list of all the files and directories in the root of my C:. Just like I would expect.


A RecursiveDirectoryIterator

So, in my limited understanding (OK, I'm being facetous - I've been fighting Crystal Reports all day, so please give me a break), by using the RecursiveDirectoryIterator, I would expect to get a list of all the files and directories and sub-directories from C:\ onwards, a complete treewalk.

<?php
$objRDI = new RecursiveDirectoryIterator("C:/");
foreach($objRDI as $key => $value)
	{
	echo "$key\n";
	}
?>

But no.

All this does is print the same list as DirectoryIterator. Admittedly, the name is now a key and the value is an object, but how is this recursive?

Either proper documentation for RecursiveDirectoryIterator (what is it recursing?) or a change to the name as it is NOT recursing is appropriate.

I've read the documentation at Helly, but it makes no sense as there no examples. It looks like I have to implement the recursion myself, so what does the class recurse?

Hopefully you can see my problem.

Richard Quadling.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-09-23 15:33 UTC] johannes@php.net
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

You need a RevursiveIteratorIterator. Have a look at 
http://cvs.php.net/php-src/ext/spl/examples/ or Marcus\' 
slides at http://talks.somabo.de 
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 23:01:26 2024 UTC