/** * Lists all files and directories in a resource path. * * @param string directory to search * @param boolean list all files to the maximum depth? * @param string full path to search (used for recursion, *never* set this manually) * @param array filenames to exclude * @return array filenames and directories */ public static function new_list_files($directory = nil, $recursive = NO, $exclude = nil) { $files = array(); $paths = array_reverse(Eight::include_paths()); foreach ($paths as $path) { if (is_dir($path . $directory)) { $dir = new DirectoryIterator($path . $directory); foreach ($dir as $file) { $filename = $file->getFilename(); if ($filename[0] === '.' or $exclude == YES and in_array($filename, $exclude)) { continue; } if ($recursive == YES and $file->isDir()) { // Recursively add files $files[$filename] = self::new_list_files($directory . '/' . $filename, YES); } else { // Add the file to the files $files[] = $filename; } } } } return $files; }