Verzeichnisstruktur phpBB-3.2.0
- Veröffentlicht
- 06.01.2017
So funktioniert es
|
Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück |
Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis. |
|
(Beispiel Datei-Icons)
|
Auf das Icon klicken um den Quellcode anzuzeigen |
GnuFindAdapter.php
001 <?php
002
003 /*
004 * This file is part of the Symfony package.
005 *
006 * (c) Fabien Potencier <fabien@symfony.com>
007 *
008 * For the full copyright and license information, please view the LICENSE
009 * file that was distributed with this source code.
010 */
011
012 namespace Symfony\Component\Finder\Adapter;
013
014 @trigger_error('The '.__NAMESPACE__.'\GnuFindAdapter class is deprecated since version 2.8 and will be removed in 3.0. Use directly the Finder class instead.', E_USER_DEPRECATED);
015
016 use Symfony\Component\Finder\Shell\Shell;
017 use Symfony\Component\Finder\Shell\Command;
018 use Symfony\Component\Finder\Iterator\SortableIterator;
019 use Symfony\Component\Finder\Expression\Expression;
020
021 /**
022 * Shell engine implementation using GNU find command.
023 *
024 * @author Jean-François Simon <contact@jfsimon.fr>
025 *
026 * @deprecated since 2.8, to be removed in 3.0. Use Finder instead.
027 */
028 class GnuFindAdapter extends AbstractFindAdapter
029 {
030 /**
031 * {@inheritdoc}
032 */
033 public function getName()
034 {
035 return 'gnu_find';
036 }
037
038 /**
039 * {@inheritdoc}
040 */
041 protected function buildFormatSorting(Command $command, $sort)
042 {
043 switch ($sort) {
044 case SortableIterator::SORT_BY_NAME:
045 $command->ins('sort')->add('| sort');
046
047 return;
048 case SortableIterator::SORT_BY_TYPE:
049 $format = '%y';
050 break;
051 case SortableIterator::SORT_BY_ACCESSED_TIME:
052 $format = '%A@';
053 break;
054 case SortableIterator::SORT_BY_CHANGED_TIME:
055 $format = '%C@';
056 break;
057 case SortableIterator::SORT_BY_MODIFIED_TIME:
058 $format = '%T@';
059 break;
060 default:
061 throw new \InvalidArgumentException(sprintf('Unknown sort options: %s.', $sort));
062 }
063
064 $command
065 ->get('find')
066 ->add('-printf')
067 ->arg($format.' %h/%f\\n')
068 ->add('| sort | cut')
069 ->arg('-d ')
070 ->arg('-f2-')
071 ;
072 }
073
074 /**
075 * {@inheritdoc}
076 */
077 protected function canBeUsed()
078 {
079 return $this->shell->getType() === Shell::TYPE_UNIX && parent::canBeUsed();
080 }
081
082 /**
083 * {@inheritdoc}
084 */
085 protected function buildFindCommand(Command $command, $dir)
086 {
087 return parent::buildFindCommand($command, $dir)->add('-regextype posix-extended');
088 }
089
090 /**
091 * {@inheritdoc}
092 */
093 protected function buildContentFiltering(Command $command, array $contains, $not = false)
094 {
095 foreach ($contains as $contain) {
096 $expr = Expression::create($contain);
097
098 // todo: avoid forking process for each $pattern by using multiple -e options
099 $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 }
109