I am trying to get permissions of a directory via FTP command "STAT" like this:
$directory_list = ftp_raw($conn_id,'STAT '.$path);
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:
drwxr-xr-x 3 user group 77824 May 13 10:15 Targetdir
This will let me parse the drwxr-xr-x string to find out that the chmod of the Targetdir is 0755.
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.
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.
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.