public function Search($pattern, $path = null) { $this->initPath(); $aResult = array(); if ($path === null) { $path = $this->path; } $aItems = \api_Utils::SearchFiles($path, $pattern); if ($aItems) { foreach ($aItems as $sItem) { if (is_dir($sItem)) { $aResult[] = new Directory($sItem); } else { $aResult[] = new File($sItem); } } } return $aResult; }