Edit report at http://bugs.php.net/bug.php?id=51763&edit=1

 ID:               51763
 Updated by:       ka...@php.net
 Reported by:      v-sumada at microsoft dot com
 Summary:          SplFileInfo::getType()
 Status:           Assigned
 Type:             Bug
 Package:          SPL related
 Operating System: All windows OS
 PHP Version:      5.3.2
 Assigned To:      pajoye

 New Comment:

As noted, the issue here is within php_stat() and its way to detect
links. php_stat() uses the S_ISLNK() macro to check if the stat.st_mode
have the bits for a like, as on Unix.



What we probably need to do is to use GetFileAttributes() and check for:
FILE_ATTRIBUTE_REPARSE_POINT.



After some further debugging it seems that the php_stream_stat_path_ex()
function makes the fail. I only tried with symbolic-linked directories,
but I would assume the cause would be the same on files. Which brings us
to the point where the bug must be located within the url_stat function
within the fopen() wrapper.


Previous Comments:
------------------------------------------------------------------------
[2010-05-08 05:07:06] cataphr...@php.net

The comment should read "information is NOT conveyed in the stat
structure".

------------------------------------------------------------------------
[2010-05-08 05:05:38] cataphr...@php.net

This is unrelated to Spl. is_link/etc. are all also windows symbolic
link agnostic. The problem here is that this information is conveyed in
the stat structure. Strictly speaking, the return of getType is not
completely incorrect -- the file type _S_IFREG and symbolic links are in
fact files or (empty) directories with reparse point data. Maybe the
best thing to do would be to change the stat function returned on
windows so that the file type is replaced with _S_IFLNK when the
directory is a junction/symlink or the file is a symlink.

------------------------------------------------------------------------
[2010-05-07 03:36:11] v-sumada at microsoft dot com

Description:
------------
The SplFileInfo::getType() For Symbolic link returns "dir" which in turn
should return "link" .This happens to be in 5.3.2 and occurs on all
windows OS.



It Correctly  returns the type of  file referenced which is for Dir  and
File . 





<?php

$symlinkdir = "/path/to/symlink"; //Symbolic link

$syminfo = new SplFileInfo($symlinkdir);

var_dump($syminfo->getType());

?>



Expected result :string(4)"Link"

Actual result : string(3) "dir" 

Test script:
---------------
<?php

$symlinkdir = "/path/to/symlink"; //Symbolic link

$syminfo = new SplFileInfo($symlinkdir);

var_dump($syminfo->getType());

?>

Expected result:
----------------
string(4)"Link"





Actual result:
--------------
string(3) "dir" 


------------------------------------------------------------------------



-- 
Edit this bug report at http://bugs.php.net/bug.php?id=51763&edit=1

Reply via email to