public function read($url = '', $recursive = false, $format = 'flat') { if (substr($url, -1) !== Application::DS) { $url .= Application::DS; } if ($this->ignore('find', $url)) { return array(); } $list = array(); $cwd = getcwd(); chdir($url); if ($handle = opendir($url)) { while (false !== ($entry = readdir($handle))) { $recursiveList = array(); if ($entry == '.' || $entry == '..') { continue; } $file = new stdClass(); $file->url = $url . $entry; if (is_dir($file->url)) { $file->url .= Application::DS; $file->type = 'dir'; } if ($this->ignore('find', $file->url)) { continue; } $file->name = $entry; if (isset($file->type)) { if (!empty($recursive)) { $directory = new dir(); $directory->ignore('list', $this->ignore()); $recursiveList = $directory->read($file->url, $recursive, $format); if ($format !== 'flat') { $file->list = $recursiveList; unset($recursiveList); } } } else { $file->type = 'file'; } if (is_link($entry)) { $file->link = true; } /* absolute url is_link wont work probably the targeting type if(is_link($file->url)){ $file->link = true; } */ $list[] = $file; if (!empty($recursiveList)) { foreach ($recursiveList as $recursive_nr => $recursive_file) { $list[] = $recursive_file; } } } } closedir($handle); return $list; }