php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #28265 Realpath, getcwd not returning true pathname
Submitted: 2004-05-04 00:07 UTC Modified: 2005-01-26 11:13 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: csaba at alum dot mit dot edu Assigned:
Status: Closed Package: Directory function related
PHP Version: 5CVS-2004-05-04 (dev) OS: Windows - all
Private report: No CVE-ID: None
 [2004-05-04 00:07 UTC] csaba at alum dot mit dot edu
Description:
------------
I am resubmitting this bug report (#17822) since the previous report seems to have been corrupted and all the developer comments gone missing!  The bug is still there, too:

[18 Jun 2002 6:20pm CEST] csaba at alum dot mit dot edu 
realpath and getcwd on Windows systems do not actually report the applicable directory, but rather a string that will !strcasecmp() with the true directory:

I have a directory name, $dir, on my Win2K system (PHP 4.2.0), but it's in all lower case, and I'd like to get the actual pathname including the capitalizations: 

Both realpath() and dirname() only muck around with the $dir string and don't hit the file system. Not only that, but getcwd() returns $dir (sans capitalizations) after I've hopped over to it with chdir($dir)! 

My only solution to this point is to pop up a level and use readdir(...) but this is wasteful, only giving me one level at a time. Isn't there a REAL realpath() for windows? 

Thanks, 
Csaba Gabor


[27 Jul 2002 11:45am CEST] sfox@php.net 
Looked into this, it looks possible to implement.  Wish me luck :)

[10 Oct 2002 10:47pm CEST] iliaa@php.net 
Any news?

[27 Oct 2002 7:27pm CET] iliaa@php.net 
This bug has been fixed in CVS.

In case this was a PHP problem, 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/.
 
In case this was a documentation problem, the fix will show up soon at http://www.php.net/manual/.

In case this was a PHP.net website problem, the change will show up on the PHP.net site and on the mirror sites in short time.
 
Thank you for the report, and for helping us make PHP better.


[15 Feb 2003 5:38pm CET] csaba at alum dot mit dot edu 
I have marked this bug as open because of the demonstration below on my PHP 4.3 build date Dec. 20, 2002; Apache 2.0.43 Filter; Win2K Pro system.

Here is the test:
<html><head><title>getcwd Problem</title></head><body>
<?php
$cwd = getcwd();
chdir (strtolower($cwd));
print "<br>" . getcwd();
print "<br>" . realpath(getcwd());
chdir (strtoupper($cwd));
print "<br>" . getcwd();
print "<br>" . realpath(getcwd());
?>
</body></html>

On my system the first 2 directories show in lower case,
the last two are in caps.
Csaba

[15 Feb 2003 7:32pm CET] iliaa@php.net 
Please try using this CVS snapshot:

  http://snaps.php.net/php4-STABLE-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php4-win32-STABLE-latest.zip

Cannot replicate using latest CVS.

[22 Feb 2003 8:03pm CET] sniper@php.net 
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.


[23 Apr 12:26am CEST] csaba at alum dot mit dot edu 
I have tested this with the latest snapshot 5.0 RC 2 of April 22 on my Win 2K Pro system and it is still a problem.  Here are the outputs that I get (I did an inititial print right after the first cwd() so you can see what windows thinks the directory is):

C:\Morph\phpDev\40gNiKU5LQ0C

c:\Morph\phpDev\40gniku5lq0c
c:\Morph\phpDev\40gniku5lq0c

C:\Morph\phpDev\40GNIKU5LQ0C
C:\Morph\phpDev\40GNIKU5LQ0C 

So it appears that the middle part is OK but the drive letter and the final directory need some shoring up.

Csaba Gabor

Reproduce code:
---------------
<html><head><title>getcwd Problem</title></head><body>
<?php
$cwd = getcwd();
print "$cwd<br>";

chdir (strtolower($cwd));
print "<br>" . getcwd();
print "<br>" . realpath(getcwd());

chdir (strtoupper($cwd));
print "<br><br>" . getcwd();
print "<br>" . realpath(getcwd());
?>
</body></html>


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-01-26 04:52 UTC] sniper@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5-win32-latest.zip


 [2005-01-26 11:13 UTC] csaba at alum dot mit dot edu
Hurrah, hurrah!  This looks fixed on my WinXP Pro (SP2)system.  I tested with (apache not yet installed):
PHP 5.1.0-dev (cli) (built: Jan 26 2005 08:25:49)

Thanks,
Csaba

I tested with:
<?php
$cwd = getcwd();
chdir (strtolower($cwd));
print "chdir(LCase(cwd));getcwd(): " . getcwd();
print "\n        realpath(getcwd()): " . realpath(getcwd());
chdir (strtoupper($cwd));
print "\nchdir(UCase(cwd));getcwd(): " . getcwd();
print "\n        realpath(getcwd()): " . realpath(getcwd());
print "\n      realpath(UCase(cwd)): " . realpath(strtoupper($cwd));
?>
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Tue Jan 26 10:01:23 2021 UTC