mode - PHP lstat command doesn't distinguish shortcuts in windows -


in windows, open dir, read files, , each file, run stat determine size, etc.

the problem when run stat on folder shortcut, comes folder, , can't see anywhere in mode bitmask might indicate this. has been true of folder shortcuts in c:\documents , settings\myusername\.

for these shortcuts, is_file returns false, is_dir returns true , is_link isn't supported in xp.

here's excerpt code (it has been trimmed down, there may bugs) :

if(($h=@opendir($root))!==false){     while (false !== ($file = readdir($h))){         if(!($file=="." || $file=="..")){             if( $stat = @lstat($root . $file) ){                 $ary[0] = $file;                 $ary[1] = $root;                 $ary[2] = date("m/d/y h:i:s", $stat['mtime']);                 if($stat['mode'] & 040000){                     $ary[3]="dir";                     $ary[4]=0;                 }else{                     $ary[3] ="file";                     $ary[4] = $stat['size'];                 }                 echo(json_encode($ary));             }         }     } } 

a workaround appreciated...

edit: winterblood's solution worked

first off - bad - it's win7 machine.

thanks winterblood quick turnaround - worked several of shortcuts, , php manual says that... however,

c:\users\myusername\appdata\local\application data

(and others) still coming directories, while winscp correctly sees them shortcuts. matter of fact, 'mode' 040777, same many real folders.

any other suggestions?

php's stat() function "follows" shortcuts/symlinks, reporting details on linked file/folder, not actual link itself.

for getting stat details on link use lstat().

more information in the php documentation on lstat.


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -