Bug #73758 [Com]: is_dir Drive:Folder returns true - unexpected behavior

From: Date: Fri, 16 Dec 2016 11:55:49 +0000
Subject: Bug #73758 [Com]: is_dir Drive:Folder returns true - unexpected behavior
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-206056@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=73758&edit=1 ID: 73758 Comment by: steve dot baldwin at publisure dot com Reported by: steve dot baldwin at publisure dot com Summary: is_dir Drive:Folder returns true - unexpected behavior Status: Not a bug Type: Bug Package: Directory function related Operating System: Windows 8.1 PHP Version: 5.6.29 Block user comment: N Private report: N New Comment: Actually I'm not sure that's correct. In the blog you linked to, in the test script an environment variable is set; // A hidden environment variable will be kept for each drive where a current directory is set // (need to set via P/Invoke as .NET blocks this) SetEnvironmentVariableW(@"=C:", @"C:\Program Files"); I believe this is what allows 'C:Foo' to resolve to C:\Program Files\Foo. If you use dirname("C:PHP") it returns C:. however if you use dirname("C:PHP\Test") it will return C:PHP. Either way it does look like PHP is actually correct regarding is_dir but windows has some odd functionality regarding how this resolves. Previous Comments: ------------------------------------------------------------------------ [2016-12-16 11:25:46] steve dot baldwin at publisure dot com Wow! thats suprising. Thank you for clarifying this. I'll close this ticket. ------------------------------------------------------------------------ [2016-12-16 11:06:32] requinix@php.net Actually "C:PHP" is a valid path. https://blogs.msdn.microsoft.com/jeremykuhne/2016/04/21/path-normalization/ ------------------------------------------------------------------------ [2016-12-16 11:01:48] steve dot baldwin at publisure dot com Description: ------------ If you call is_dir("D:MyFolder") when both the drive (D) and the folder (MyFolder) exists it will return true. However windows will not resolve D:MyFolder as a valid path because a forward/or back slash is omitted after the root drive. The correct path is D:\MyFolder or D:/MyFolder and PHP should be returning false instead of true. Test script: --------------- //change this below to a valid drive and folder but omit the \\ $path = "C:PHP"; assert(is_dir($path) == false); Actual result: -------------- Warning: assert(): Assertion failed ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=73758&edit=1

« previous php.bugs (#206056) next »