php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #42027 is_file() / is_dir() matches file/dirnames with wildcard char or trailing slash
Submitted: 2007-07-18 11:38 UTC Modified: 2007-07-24 09:08 UTC
From: mahesh dot vemula at in dot ibm dot com Assigned: dmitry
Status: Closed Package: Filesystem function related
PHP Version: 5.2CVS-2007-07-23 OS: win32 only
Private report: No CVE-ID:
 [2007-07-18 11:38 UTC] mahesh dot vemula at in dot ibm dot com
Description:
------------
is_file() matches for a file name given with wild-card character/trailing slash on Windows, but not on Linux. When wild-card char/trailing slash is given in the file name as input to the function, the function returns false on Linux. 
In the same manner, is_dir() matches for a dir name given with wild-card character on Windows, but not on Linux. When wild-card is given in the dir name as input to the function, the function returns false on Linux.  
A consistent behavior of the function is expected.


Environment:
Operating System: RHEL 4
PHP Version: PHP 5.2 
Configure Setup: ./configure


Reproduce code:
---------------
<?php
fclose( fopen("test.tmp", "w") );
var_dump( is_file("test.tmp") );
var_dump( is_file("test.tmp/") );
var_dump( is_file("*.tmp") );
unlink("test.tmp");

mkdir("temp");
var_dump( is_dir("temp") );
var_dump( is_dir("temp/") );
var_dump( is_dir("*mp") );
rmdir("temp");
?>


Expected result:
----------------
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)


Actual result:
--------------
bool(true)
bool(false)
bool(false)
bool(true)
bool(true)
bool(false)


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-07-18 15:37 UTC] jani@php.net
Obviously Windows side is doing it wrong. I expect wildcards in filenames passed to is_file to return false.
 [2007-07-23 08:35 UTC] tony2001@php.net
Windows behaviour is definitely wrong, "*.tmp" is not a file.
 [2007-07-23 11:26 UTC] jani@php.net
GetFileAttributesEx accepts wildcards. There needs to be some check for that and just simply return false for those on win32?

Assigned to Dmitry who added the win32 stuff into TSRM/tsrm_virtual_cwd.c for this.
 [2007-07-24 09:08 UTC] dmitry@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Fri Apr 25 07:02:14 2014 UTC