note 36643 deleted from class.dir by aidan
| From: | aidan@php.net | Date: | Sun, 05 Sep 2004 07:22:27 +0000 |
| Subject: | note 36643 deleted from class.dir by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-76043@lists.php.net to get a copy of this message | ||
Note Submitter:
----
that recursive_ls works great on a UNIX system, but not on a Windows one. You'll find that you
have to change the "/" in the two lines of the function to "\\" (at least on my
version of PHP).
And since Windows reports directory names as "DirName" instead of "DirName\" (at
least on my version) you'll have to move around the "\\" a little bit as well. Here
is the version that I got to work on my system:
<?
function recursive_ls($listing, $directory, $count)
{
$dummy = $count;
if ($handle = opendir($directory))
{
while ($file = readdir($handle))
{
if ($file=='.' || $file=='..') continue;
elseif ($h = @opendir($directory."\\".$file))
{
closedir($h);
$count = -1;
$listing["$file"] = array();
recursive_ls(&$listing["$file"], $directory."\\".$file,
$count + 1);
}
else
{
$listing[$dummy] = $file;
$dummy = $dummy + 1;
}
}
}
closedir($handle);
return ($listing);
}
//Example call
$testlist = recursive_ls($direcs, "E:\\unsorted\\messedup", 0);
?>