I'll note that the erroneous command is the is_dir($file).. this causes 
the problem.

Mike

Mike Eheler wrote:

> Consider this code for traversing through a directory structure:
> 
> <?php
> 
> function traverse($path='.') {
>   $path = realpath($path);
>   $dir = opendir($path);
> 
>   echo "\nDirectory : $path\n";
>   echo str_pad('',76,'-')."\n";
> 
>   while (false !== ($file = readdir($dir))) {
>     if (is_dir($file) && $file != '.' && $file != '..') {
>       traverse("$path/$file");
>       echo $file;
>     }
>   }
> 
>   closedir($dir);
> }
> 
> echo '<pre>';
> traverse();
> echo '</pre>';
> 
> ?>
> 
> Now when I run it in a directory that has a file with spaces in it's 
> name.. for examples purposes, the file willbe called "file name with 
> spaces".
> 
> Directory : /home/mike/php/test
> ---------------------------------------------------------------------------- 
> 
> Warning:  stat failed for file name with spaces (errno=2 - No such file 
> or directory) in /home/mike/php/dirdump.php on line 10
> 
> Any ideas why this error happens and what I can do to get around it?
> 
> Mike
> 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to