/** * Returns an FileIterator for the files directly in this folder (not recursive). * * The returned Iterator will return objects of the type File, but if the second parameter is * set to FileSystem::RETURN_PATHS just the paths are returned. * * The first argument is a regular expression pattern that is used to filter the result. The * pattern is applied only on the file name, not on the whole path. * If the first parameter starts with a dot a faster filter only on the file extension will be * set. This causes that a regular expression pattern can't start with a dot! * * @param int Whether to return objects or paths * @param string Search pattern (regular expression or a file extension starting with a dot) * @return array Returns the array or null on failrue */ public function getFileIterator($pattern = null, $mode = FileSystem::RETURN_OBJECTS) { $iterator = new FileIterator($this->path); $iterator->setMode($mode); if ($pattern !== null) { if ($pattern !== null && strlen($pattern) > 0 && $pattern[0] == '.') { $extension = substr($pattern, 1); $iterator->setExtensionFilter($extension); } elseif ($pattern !== null) { $iterator->setFilter($pattern); } } return $iterator; }