php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #30981 is_dir reports a directory exists when named one thing but not another
Submitted: 2004-12-04 04:59 UTC Modified: 2004-12-06 08:27 UTC
From: andy dot thoreson at verizon dot net Assigned:
Status: Not a bug Package: Directory function related
PHP Version: 4.3.10RC1 OS: Windows 2000
Private report: No CVE-ID: None
 [2004-12-04 04:59 UTC] andy dot thoreson at verizon dot net
Description:
------------
Was trying to write code that recursively scanned files in a directory tree and Apache was crashing as soon as I added the recursion...but that's another issue. In the course of debugging that, I found this one simple bug:

I run the following code (nothing else run in php file):
print "1:[".is_dir("D:\Program Files\Apache Group\Apache\htdocs\Utils\Old_Ocean_Backup")."]";
print "<br>";
print "2:[".is_dir("D:\Program Files\Apache Group\Apache\htdocs\Utils\Old_Ocean_Backup\testx")."]";
print "<br>";

The first folder always comes back as existing (returns true/1). 

The second one does not. It is just a directory I made from windows explorer (right-click, new folder).

When I rename it, in explorer, to "abc" and reload the php page (with name changed from "testx" to "abc" in code as well), is_dir says it *does* exist. Renaming to "abcx" or "testxx" etc does the same..."abcx" exists, "textxx" does not.

Renaming it back and forth from explorer reproduces the same results.

File system rights don't seem to be the issue.

Strangely, readdir does see the directory such as:
$handle=opendir("D:\Program Files\Apache Group\Apache\htdocs\Utils\Old_Ocean_Backup");
while ($file = readdir($handle)) {
...}

Installed a fresh version of PHP and Apache today after first running into problem (was on apache 2.0 and PHP 4.3 from last week): 
PHP 4.3.10RC2-dev.
Apache 1.3
Windows NT 5.0 build 2195 (Windows 2000)

Reproduce code:
---------------
See description

Expected result:
----------------
Expected the code to treat the existance of a directory the same regardless of its name.

Actual result:
--------------
Code treats the existance of a directory different based on directory name.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-12-05 03:57 UTC] andy dot thoreson at verizon dot net
Did another test:
Made a directory for every letter of the alphabet and it seems as if php just doesn't like directories that start with the letters "n", "r", and "t". I tried renaming directories to various combinations and that seems to remain the case.

Reset permissions to all subdirectories of c:\aaa, security set so "everyone" has "full control".

<pre>
$bd="c:\aaa";
print "a\t[".is_dir($bd."\a")."]"."<br>";
print "b\t[".is_dir($bd."\b")."]"."<br>";
print "c\t[".is_dir($bd."\c")."]"."<br>";
print "d\t[".is_dir($bd."\d")."]"."<br>";
print "e\t[".is_dir($bd."\e")."]"."<br>";
print "f\t[".is_dir($bd."\f")."]"."<br>";
print "g\t[".is_dir($bd."\g")."]"."<br>";
print "h\t[".is_dir($bd."\h")."]"."<br>";
print "i\t[".is_dir($bd."\i")."]"."<br>";
print "j\t[".is_dir($bd."\j")."]"."<br>";
print "k\t[".is_dir($bd."\k")."]"."<br>";
print "l\t[".is_dir($bd."\l")."]"."<br>";
print "m\t[".is_dir($bd."\m")."]"."<br>";
print "n\t[".is_dir($bd."\n")."]"."<br>";
print "o\t[".is_dir($bd."\o")."]"."<br>";
print "p\t[".is_dir($bd."\p")."]"."<br>";
print "q\t[".is_dir($bd."\q")."]"."<br>";
print "r\t[".is_dir($bd."\r")."]"."<br>";
print "s\t[".is_dir($bd."\s")."]"."<br>";
print "t\t[".is_dir($bd."\t")."]"."<br>";
print "u\t[".is_dir($bd."\u")."]"."<br>";
print "v\t[".is_dir($bd."\v")."]"."<br>";
print "w\t[".is_dir($bd."\w")."]"."<br>";
print "x\t[".is_dir($bd."\x")."]"."<br>";
print "y\t[".is_dir($bd."\y")."]"."<br>";
print "z\t[".is_dir($bd."\z")."]"."<br>";
</pre>
This returns
<pre>
1a [1]
b [1]
c [1]
d [1]
e [1]
f [1]
g [1]
h [1]
i [1]
j [1]
k [1]
l [1]
m [1]
n []
o [1]
p [1]
q [1]
r []
s [1]
t []
u [1]
v [1]
w [1]
x [1]
y [1]
z [1]
</pre>
 [2004-12-06 08:27 UTC] tony2001@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

Use forward slashes in your path or single quotes to quote the path string.
\r, \n and \t are special chars, that are treated as "carriage return", "new line" and "tabulation" correspondingly.
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Fri Dec 04 18:01:23 2020 UTC