Search the specified directory tree with the specified pattern. Return
an array containing all matching files (no directories included).
public search ( string $pattern, string $directory, string $type = 'php', boolean $fullpath = true, string $match = 'files' ) : array | ||
$pattern | string | the pattern to match every file with. |
$directory | string | the directory tree to search in. |
$type | string | the type of regular expression support to use, either 'php', 'perl' or 'shell'. |
$fullpath | boolean | whether the regex should be matched against the full path or only against the filename |
$match | string | can be either 'files', 'dirs' or 'both' to specify the kind of list to return |
Результат | array | a list of files matching the pattern parameter in the the directory path specified by the directory parameter |
/** * Returns an array of available handlers containing * handler name -> info pairs. * @param $p_path * @return array */ public static function availableHandlers($p_path = null) { if (is_null($p_path)) { $path = dirname(__FILE__) . DIR_SEP. 'cache'; } else { $path = $p_path; } require_once(dirname(dirname(__FILE__)).'/include/pear/File/Find.php'); $includeFiles = File_Find::search('/^TemplateCacheHandler_[^.]*\.php$/', $path, 'perl', false); $handlers = array(); foreach ($includeFiles as $includeFile) { if (preg_match('/TemplateCacheHandler_([^.]+)\.php/', $includeFile, $matches) == 0) { continue; } require_once $includeFile; $handlerName = $matches[1]; $className = "TemplateCacheHandler_$handlerName"; if (class_exists($className)) { $cacheHandler = new $className; $handlers[$handlerName] = array( 'is_supported'=>$cacheHandler->isSupported(), 'file'=>"$path/TemplateCacheHandler_$handlerName.php", 'description'=>$cacheHandler->description()); } } return $handlers; }
/** * Delete cached data of given component/section * * @access public * @param string $component * @param string $section * @param string $params * @return bool */ function delete($component = null, $section = null, $params = null) { if (!is_null($params)) { $params = is_array($params) ? implode('_', $params) : $params; } else { $params = ''; } require_once PEAR_PATH . 'File/Find.php'; $match = is_null($component) ? '' : $component; $match .= '.' . (is_null($section) ? '' : $section); $match .= empty($params) ? '' : '.' . $params; $files =& File_Find::search('/' . $match . '/i', $this->_path, 'perl', false, 'files'); foreach ($files as $file) { Jaws_Utils::Delete($file); } return true; }
/** * Returns list of files parsed * * Returns list of files parsed, depending of restrictive parser options. * * @param mixed $dir The directory name where to look files * @param array $options An array of parser options. See parseData() method. * * @access public * @return array list of files that should be parsed * @since version 1.8.0b2 (2008-06-03) */ function getFilelist($dir, $options) { $skipped = array(); $ignored = array(); $options = array_merge($this->options, $options); $options['file_ext'] = array_map('strtolower', $options['file_ext']); if ($dir[strlen($dir) - 1] == '/' || $dir[strlen($dir) - 1] == '\\') { $dir = substr($dir, 0, -1); } // use system directory separator rather than forward slash by default $ff = new File_Find(); $ff->dirsep = DIRECTORY_SEPARATOR; // get directory list that should be ignored from scope $ignore_dirs = array(); if (count($options['ignore_dirs']) > 0) { foreach ($options['ignore_dirs'] as $cond) { $cond = str_replace('\\', "\\\\", $cond); $dirs = $ff->search('`' . $cond . '`', $dir, 'perl', true, 'directories'); $ignore_dirs = array_merge($ignore_dirs, $dirs); } } // get file list that should be ignored from scope $ignore_files = array(); if (count($options['ignore_files']) > 0) { foreach ($options['ignore_files'] as $cond) { $cond = str_replace('\\', "\\\\", $cond); $files = $ff->search('`' . $cond . '`', $dir, 'perl', true, 'files'); $ignore_files = array_merge($ignore_files, $files); } } list($directories, $files) = $ff->maptree($dir); foreach ($files as $file) { $file_info = pathinfo($file); if ($options['recurse_dir'] == false && $file_info['dirname'] != $dir) { $skipped[] = $file; continue; } if (in_array($file_info['dirname'], $ignore_dirs)) { $ignored[] = $file; } elseif (in_array($file, $ignore_files)) { $ignored[] = $file; } else { if (isset($file_info['extension']) && in_array(strtolower($file_info['extension']), $options['file_ext'])) { continue; } $ignored[] = $file; } } $files = PHP_CompatInfo_Parser::_arrayDiff($files, array_merge($ignored, $skipped)); $this->directories = PHP_CompatInfo_Parser::_arrayDiff($directories, $ignore_dirs); $this->ignored_files = $ignored; return $files; }
/** * Searches for classes that process actions. Returns an array of * action names. * * @return array */ public static function ReadAvailableActions() { if (is_array(MetaAction::$m_availableActions)) { return MetaAction::$m_availableActions; } if (self::FetchActionsFromCache()) { return self::$m_availableActions; } require_once('File/Find.php'); $actions = array(); $basePaths = array('.'); foreach (CampPlugin::GetEnabled() as $CampPlugin) { $basePaths[] = $CampPlugin->getBasePath(); } foreach ($basePaths as $basePath) { $directoryPath = $GLOBALS['g_campsiteDir'].'/'.$basePath.'/template_engine/metaclasses'; $actionIncludeFiles = File_Find::search('/^MetaAction[^.]*\.php$/', $directoryPath, 'perl', false); foreach ($actionIncludeFiles as $includeFile) { if (preg_match('/MetaAction([^.]+)\.php/', $includeFile, $matches) == 0 || strtolower($matches[1]) == 'request') { continue; } require_once($includeFile); $actionName = $matches[1]; if (class_exists('MetaAction'.$actionName)) { $actions[self::TranslateProperty($actionName)] = array('name'=>$actionName, 'file'=>"$directoryPath/MetaAction$actionName.php"); } } } self::$m_availableActions = $actions; self::StoreActionsInCache(); return self::$m_availableActions; }
/** * Returns an array of available engines containing * engine name -> info pairs. * @param $p_path * @return array */ public static function AvailableEngines($p_path = null) { if (is_null($p_path)) { $path = dirname(__FILE__); } else { $path = $p_path; } require_once(dirname(dirname(dirname(__FILE__))).'/include/pear/File/Find.php'); $includeFiles = File_Find::search('/^CacheEngine_[^.]*\.php$/', $path, 'perl', false); $engines = array(); foreach ($includeFiles as $includeFile) { if (preg_match('/CacheEngine_([^.]+)\.php/', $includeFile, $matches) == 0) { continue; } require_once($includeFile); $engineName = $matches[1]; $className = "CacheEngine_$engineName"; if (class_exists($className)) { $cacheEngine = new $className; $engines[$engineName] = array( 'is_supported'=>$cacheEngine->isSupported(), 'page_caching_supported'=>$cacheEngine->pageCachingSupported(), 'file'=>"$path/CacheEngine_$engineName.php", 'description'=>$cacheEngine->description()); } } return $engines; }
$error = __("Could not create incoming directory: %s.", $tempdir); } else { if (!@chdir($tempdir)) { $error = __("Could not change directory to %s.", $tempdir); } else { $tar = new Archive_Tar($_FILES['pfile']['tmp_name']); $extract = $tar->extract(); if (!$extract) { $error = __("Unknown file format for uploaded file."); } } } } # Find the PKGBUILD if (!$error) { $pkgbuild = File_Find::search('PKGBUILD', $tempdir); if (count($pkgbuild)) { $pkgbuild = $pkgbuild[0]; $pkg_dir = dirname($pkgbuild); } else { $error = __("Error trying to unpack upload - PKGBUILD does not exist."); } } # if no error, get list of directory contents and process PKGBUILD # TODO: This needs to be completely rewritten to support stuff like arrays # and variable substitution among other things. if (!$error) { # process PKGBUILD - remove line concatenation # $pkgbuild = array(); $fp = fopen($pkg_dir . "/PKGBUILD", "r");