本文整理汇总了PHP中Finder::findFiles方法的典型用法代码示例。如果您正苦于以下问题:PHP Finder::findFiles方法的具体用法?PHP Finder::findFiles怎么用?PHP Finder::findFiles使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Finder
的用法示例。
在下文中一共展示了Finder::findFiles方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getBackups
/**
* Return array of existing backup files
* @param string $path
* @return array of SplFileInfo
*/
public function getBackups($path)
{
$files = array();
$finder = Finder::findFiles('*.zip')->in($path . 'backups/');
try {
foreach ($finder->orderByName() as $file) {
$files[] = $file->getBasename();
}
return array_reverse($files);
} catch (UnexpectedValueException $e) {
return array();
}
}
示例2: createFileIterator
/**
* Creates an iterator scaning directory for PHP files, subdirectories and 'netterobots.txt' files.
* @return Iterator
*/
private function createFileIterator($dir)
{
if (!is_dir($dir)) {
return new ArrayIterator(array(new SplFileInfo($dir)));
}
$ignoreDirs = is_array($this->ignoreDirs) ? $this->ignoreDirs : preg_split('#[,\\s]+#', $this->ignoreDirs);
$disallow = array();
foreach ($ignoreDirs as $item) {
if ($item = realpath($item)) {
$disallow[$item] = TRUE;
}
}
$iterator = Finder::findFiles(is_array($this->acceptFiles) ? $this->acceptFiles : preg_split('#[,\\s]+#', $this->acceptFiles))->filter(create_function('$file', 'extract(NCFix::$vars[' . NCFix::uses(array('disallow' => &$disallow)) . '], EXTR_REFS);
return !isset($disallow[$file->getPathname()]);
'))->from($dir)->exclude($ignoreDirs)->filter($filter = create_function('$dir', 'extract(NCFix::$vars[' . NCFix::uses(array('disallow' => &$disallow)) . '], EXTR_REFS);
$path = $dir->getPathname();
if (is_file("$path/netterobots.txt")) {
foreach (file("$path/netterobots.txt") as $s) {
if (preg_match(\'#^(?:disallow\\\\s*:)?\\\\s*(\\\\S+)#i\', $s, $matches)) {
$disallow[$path . str_replace(\'/\', DIRECTORY_SEPARATOR, rtrim(\'/\' . ltrim($matches[1], \'/\'), \'/\'))] = TRUE;
}
}
}
return !isset($disallow[$path]);
'));
$filter(new SplFileInfo($dir));
return $iterator;
}
示例3: __construct
public function __construct($filePath, $fileMask = 'latest.log*', $exclude = '*lck')
{
$this->finder = Finder::findFiles($fileMask)->exclude($exclude)->in($filePath);
}
示例4: getImages
/**
* return paths to all images within given $searchPath
*
* @param string path to search for images
* @param string base dirname path of given model used to construct relative path
* @param bool use relative|"filesystem absolute" paths to images ?
* @return array
*/
public static function getImages($searchPath, $baseDir = null, $useRelativePath = true)
{
$images = Finder::findFiles('*.jpg')->in($searchPath);
if ($useRelativePath) {
if (!$baseDir) {
throw new ArgumentOutOfRangeException('$baseDir MUST be set if $useRelativePath==true');
}
$retImages = array();
$relativePath = self::getRelativePath($baseDir);
foreach ($images as $img) {
array_push($retImages, str_replace(array($baseDir, '\\'), array($relativePath, '/'), $img->getFilename()));
}
return $retImages;
} else {
return $images;
}
}
示例5: getAvailableJars
/**
* return all filenames that are already downloaded
* @param string $path
* @return array 'filename' => version
*/
public function getAvailableJars($path)
{
$result = array();
$regex = substr($this->config['regex'], 1, -1);
foreach (Finder::findFiles($regex)->in($path)->orderByName() as $file) {
$result[$file->getFilename()] = $this->getVersionFromFileName($file->getFilename());
}
return array_reverse($result);
}
示例6: filesSync
public static function filesSync($id_page, $syncDir)
{
$log = array('new' => array(), 'changed' => array());
$dir = Environment::getVariable('dataDir');
foreach (Finder::findFiles('*')->from("{$dir}/filesSync/{$syncDir}") as $fullpath) {
$origpath = str_replace($dir, '', $fullpath);
$f = self::getFileByOrigpath($origpath);
$new = false;
if (!$f) {
$new = true;
$f = self::createNew($id_page, $origpath, 'end');
$f->origpath = str_replace('\\', '/', $origpath);
$f->visible = 1;
}
if ($new or $f->fileMetricsChanged()) {
$f->fileMetricsUpdate();
//calls save() (for the origpath above)
$f->generatePreviewImage();
$f->clearPreviewCache();
$log[$new ? 'new' : 'changed'][] = $f->name;
}
}
return $log;
}