[ Index ] |
PHP Cross Reference of phpBB-3.2.11-deutsch |
[Summary view] [Print] [Text view]
1 <?php 2 3 /* 4 * This file is part of the Symfony package. 5 * 6 * (c) Fabien Potencier <fabien@symfony.com> 7 * 8 * For the full copyright and license information, please view the LICENSE 9 * file that was distributed with this source code. 10 */ 11 12 namespace Symfony\Component\Finder\Adapter; 13 14 @trigger_error('The '.__NAMESPACE__.'\GnuFindAdapter class is deprecated since Symfony 2.8 and will be removed in 3.0. Use directly the Finder class instead.', E_USER_DEPRECATED); 15 16 use Symfony\Component\Finder\Expression\Expression; 17 use Symfony\Component\Finder\Iterator\SortableIterator; 18 use Symfony\Component\Finder\Shell\Command; 19 use Symfony\Component\Finder\Shell\Shell; 20 21 /** 22 * Shell engine implementation using GNU find command. 23 * 24 * @author Jean-François Simon <contact@jfsimon.fr> 25 * 26 * @deprecated since 2.8, to be removed in 3.0. Use Finder instead. 27 */ 28 class GnuFindAdapter extends AbstractFindAdapter 29 { 30 /** 31 * {@inheritdoc} 32 */ 33 public function getName() 34 { 35 return 'gnu_find'; 36 } 37 38 /** 39 * {@inheritdoc} 40 */ 41 protected function buildFormatSorting(Command $command, $sort) 42 { 43 switch ($sort) { 44 case SortableIterator::SORT_BY_NAME: 45 $command->ins('sort')->add('| sort'); 46 47 return; 48 case SortableIterator::SORT_BY_TYPE: 49 $format = '%y'; 50 break; 51 case SortableIterator::SORT_BY_ACCESSED_TIME: 52 $format = '%A@'; 53 break; 54 case SortableIterator::SORT_BY_CHANGED_TIME: 55 $format = '%C@'; 56 break; 57 case SortableIterator::SORT_BY_MODIFIED_TIME: 58 $format = '%T@'; 59 break; 60 default: 61 throw new \InvalidArgumentException(sprintf('Unknown sort options: %s.', $sort)); 62 } 63 64 $command 65 ->get('find') 66 ->add('-printf') 67 ->arg($format.' %h/%f\\n') 68 ->add('| sort | cut') 69 ->arg('-d ') 70 ->arg('-f2-') 71 ; 72 } 73 74 /** 75 * {@inheritdoc} 76 */ 77 protected function canBeUsed() 78 { 79 return Shell::TYPE_UNIX === $this->shell->getType() && parent::canBeUsed(); 80 } 81 82 /** 83 * {@inheritdoc} 84 */ 85 protected function buildFindCommand(Command $command, $dir) 86 { 87 return parent::buildFindCommand($command, $dir)->add('-regextype posix-extended'); 88 } 89 90 /** 91 * {@inheritdoc} 92 */ 93 protected function buildContentFiltering(Command $command, array $contains, $not = false) 94 { 95 foreach ($contains as $contain) { 96 $expr = Expression::create($contain); 97 98 // todo: avoid forking process for each $pattern by using multiple -e options 99 $command 100 ->add('| xargs -I{} -r grep -I') 101 ->add($expr->isCaseSensitive() ? null : '-i') 102 ->add($not ? '-L' : '-l') 103 ->add('-Ee')->arg($expr->renderPattern()) 104 ->add('{}') 105 ; 106 } 107 } 108 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Nov 11 20:33:01 2020 | Cross-referenced by PHPXref 0.7.1 |