/**
* Returns array of strings containing all files and folders in the specified local directory.
* @param $dir
* @param $omitSymlinks
* @param string $prefix
* @return array array of files and folders names relative to the $path
* or an empty array if the directory $path is empty,
* <br />
* false if $path is not a directory or does not exist.
* @throws Exception
* @internal param string $path path to directory to scan.
*/
private static function listFilesInDirectory($dir, $omitSymlinks, $prefix = '')
{
if (!is_dir($dir)) {
return false;
}
$excludes = array(".", "..");
$result = array();
$files = self::localScandir($dir);
if (!$files) {
return array();
}
foreach ($files as $file) {
if (!in_array($file, $excludes)) {
$path = $dir . DIRECTORY_SEPARATOR . $file;
if (is_link($path)) {
if ($omitSymlinks) {
continue;
} else {
$result[] = $prefix . $file;
}
} else {
if (is_dir($path)) {
$result[] = $prefix . $file . DIRECTORY_SEPARATOR;
$subs = elFinderVolumeFTP::listFilesInDirectory($path, $omitSymlinks, $prefix . $file . DIRECTORY_SEPARATOR);
if ($subs) {
$result = array_merge($result, $subs);
}
} else {
$result[] = $prefix . $file;
}
}
}
}
return $result;
}