ID:               24171
 Updated by:       [EMAIL PROTECTED]
 Reported By:      php at webfreezer dot com
-Status:           Feedback
+Status:           Bogus
 Bug Type:         Directory function related
 Operating System: Windows XP
 PHP Version:      4.3.2
 New Comment:

It's just broken script. Not a bug.



Previous Comments:
------------------------------------------------------------------------

[2003-06-13 07:17:53] [EMAIL PROTECTED]

while ($file = readdir ($handle)) {
    if (is_dir($file))

This looks bogus... shouldn't you be testing:
is_dir($baseDir . DIRECTORY_SEPARATOR . $file)
instead?


------------------------------------------------------------------------

[2003-06-13 07:14:06] php at webfreezer dot com

Description:
------------
Hi,

this bug has been described before however everyone seemed to make a
mistake in the report.

Create this directory/file structure in the root of drive C:

- testDir
  -- Directory01
  -- Directory02
  -- Directory03
  -- file01.txt
  -- file02.txt
  -- file03.txt

Then start the script below.
The BUG occurs when using a non-relative directory, i.e. an ABSOULTE
path.

The documentation states "Returns TRUE if the filename exists and is a
directory. If filename is a relative filename, it will be checked
relative to the current working directory."

It seems that a check is only performed in the current directory. If
you uncomment the chdir line everything works fine!

Please fix this reproducible bug!
(Apache 1.3.27, PHP 4.3.2)


Reproduce code:
---------------
$baseDir="c:/testDir";
function parseDir($baseDir)
{
        [EMAIL PROTECTED]($baseDir); 
        if($handle)
        {
                while ($file = readdir ($handle))
                {
                    if (is_dir($file))
                        {
                                echo $file." is a directory!<br>";
                    } else {
                                echo $file." is NOT a directory!<br>";
                        }
                }
                @closedir($handle);
        }
}
//chdir("c:/testDir");
parseDir("c:/testDir");

Expected result:
----------------
. is a directory!
.. is a directory!
Directory01 is a directory!
Directory02 is a directory!
Directory03 is a directory!
file01.txt is NOT a directory!
file02.txt is NOT a directory!
file03.txt is NOT a directory!


Actual result:
--------------
. is a directory!
.. is a directory!
Directory01 is NOT a directory!
Directory02 is NOT a directory!
Directory03 is NOT a directory!
file01.txt is NOT a directory!
file02.txt is NOT a directory!
file03.txt is NOT a directory!



------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=24171&edit=1

Reply via email to