#37918 [Asn->Fbk]: file_exists() failes on long filenames (gt 259)
ID: 37918
Updated by: nlopess@php.net
Reported By: mrueegg at metaworx dot ch
-Status: Assigned
+Status: Feedback
Bug Type: Filesystem function related
Operating System: Windows NT 5.1 build 2600 (WiXP)
PHP Version: 5CVS-2006-06-26 (snap)
-Assigned To: nlopes
+Assigned To: nlopess
New Comment:
Please try using this CVS snapshot:
http://snaps.php.net/php5.2-latest.tar.gz
For Windows:
http://snaps.php.net/win32/php5.2-win32-latest.zip
I cannot reproduce. Please try the snapshot.
Previous Comments:
------------------------------------------------------------------------
[2006-06-26 16:10:26] tony2001@php.net
Nuno, IIRC you fixed the previous one, could you please check this out
too?
------------------------------------------------------------------------
[2006-06-26 16:01:16] mrueegg at metaworx dot ch
Description:
------------
on my windows system the function file_exists() returns true whenever
the full qualified file path has more than a total of 259 characters.
if the path is relative, the cwd will be prepended and counted (e.g.
260-28=232).
i testet it with the snapshot of today (26-Jun-2006 16:19) as well.
plain php.exe, no changes to modules or php.ini. same result.
i use an immaginary filename in the root of 'C:\'. the file obviously
does not exist.
refer to http://bugs.php.net/bug.php?id=31347
describing the similar
error with strlen > 255.
Reproduce code:
---------------
<?php
echo php_uname();
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
echo "Running on Windows with PHP ", phpversion(), "\n";
$root = "c:".DIRECTORY_SEPARATOR;
} else {
die("problem could not be reproduced on linux (debian with PHP
5.1.2-1+b1)\n");
}
$max = 260;
$t = $root.str_repeat('x', $max - strlen($root));
var_dump(strlen($t));
var_dump(file_exists($t));
$t = $root.str_repeat('x', $max - strlen($root) - 1);
var_dump(strlen($t));
var_dump(file_exists($t));
echo "\nif no root is given, then cwd is prepended:\n";
var_dump(getcwd().DIRECTORY_SEPARATOR);
var_dump(strlen(getcwd().DIRECTORY_SEPARATOR));
echo "\n";
$t = str_repeat('x', $max - strlen(getcwd().DIRECTORY_SEPARATOR));
var_dump(strlen($t));
var_dump(file_exists($t));
$t = str_repeat('x', $max - strlen(getcwd().DIRECTORY_SEPARATOR) - 1);
var_dump(strlen($t));
var_dump(file_exists($t));
Expected result:
----------------
Windows NT MWXDEV 5.1 build 2600
Running on Windows with PHP 5.1.4
int(260)
bool(false)
int(259)
bool(false)
if no root is given, then cwd is prepended:
string(28) "P:\Programming\xampp\htdocs\"
int(28)
int(232)
bool(false)
int(231)
bool(false)
an exception/warning would also be acceptable. but in case of doubt the
function should return false.
Actual result:
--------------
Windows NT MWXDEV 5.1 build 2600
Running on Windows with PHP 5.1.4
int(260)
bool(true)
int(259)
bool(false)
if no root is given, then cwd is prepended:
string(28) "P:\Programming\xampp\htdocs\"
int(28)
int(232)
bool(true)
int(231)
bool(false)
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=37918&edit=1
Thread (4 messages)