title: PHP lstat command doesn't distinguish shortcuts in windows
body: <p>In windows, I open a dir, read the files, and for each file, run stat to determine the size, etc.</p>
  
  <p>The problem is that when I run stat on a folder SHORTCUT, it comes back as a FOLDER, and I can't see anywhere in the <code>mode</code> bitmask that might indicate this. This has been true for all of the folder shortcuts in <code>c:\Documents and Settings\myUserName\</code>.</p>
  
  <p>For these shortcuts, <code>is_file</code> returns <code>false</code>, <code>is_dir</code> returns <code>true</code> and <code>is_link</code> isn't supported in XP.</p>
  
  <p>Here's an excerpt from my code (it has been trimmed down, so there may be bugs) :</p>
  
  <pre><code>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'] &amp; 040000){
                      $ary[3]="dir";
                      $ary[4]=0;
                  }else{
                      $ary[3] ="file";
                      $ary[4] = $stat['size'];
                  }
                  echo(json_encode($ary));
              }
          }
      }
  }
  </code></pre>
  
  <p>A workaround for this will be appreciated...</p>
  
  <p><strong>EDIT: Winterblood's solution almost worked</strong></p>
  
  <p>First off - my bad - it's a win7 machine.</p>
  
  <p>Thanks Winterblood for the quick turnaround - this worked for several of the shortcuts, and the PHP manual says just that... However, </p>
  
  <p>c:\users\myUserName\AppData\Local\Application Data</p>
  
  <p>(and others) are still coming back as directories, while winSCP correctly sees them as shortcuts. As a matter of fact, the 'mode' is 040777, which is exactly the same as many real folders.</p>
  
  <p>Any other suggestions?</p>