title: Getting directory's permissions via FTP
body: <p>I am trying to get permissions of a directory via FTP command "STAT" like this:</p>
  
  <pre><code>$directory_list = ftp_raw($conn_id,'STAT '.$path);
  </code></pre>
  
  <p>The above command lists entire directory contents , including files and subdirs. I then search the returned data array for the directory i need to check, and retrieve something like:</p>
  
  <pre><code>drwxr-xr-x   3 user  group     77824 May 13 10:15 Targetdir
  </code></pre>
  
  <p>This will let me parse the drwxr-xr-x string to find out that the chmod of the Targetdir is 0755.</p>
  
  <p>Problem is, when the containing directory has 5000 files. A) It takes a very long time, and B)  the ftp_raw function just returns empty array 1 in 10 runs. I don't know if it's timing out or what exactely is the problem.</p>
  
  <p>Is there are a better way to find directory's permissions ? Is there a way to limit number of retrieved fiels in "STAT" command ? I really need just the top 5 , no need for the other 4995 files.</p>
  
  <p>Does anyone know, why would my command NOT run 100% of the time? Why would it break ? I cannot even reproduce my error, it happens randomly.</p>