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.
Auf den Verzeichnisnamen klicken, dies zeigt nur das Verzeichnis mit Inhalt an

(Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

BsdFindAdapter.php

Zuletzt modifiziert: 09.10.2024, 12:56 - Dateigröße: 2.98 KiB


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__.'\BsdFindAdapter 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 BSD 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 BsdFindAdapter extends AbstractFindAdapter
029  {
030      /**
031       * {@inheritdoc}
032       */
033      public function getName()
034      {
035          return 'bsd_find';
036      }
037   
038      /**
039       * {@inheritdoc}
040       */
041      protected function canBeUsed()
042      {
043          return in_array($this->shell->getType(), array(Shell::TYPE_BSD, Shell::TYPE_DARWIN)) && parent::canBeUsed();
044      }
045   
046      /**
047       * {@inheritdoc}
048       */
049      protected function buildFormatSorting(Command $command, $sort)
050      {
051          switch ($sort) {
052              case SortableIterator::SORT_BY_NAME:
053                  $command->ins('sort')->add('| sort');
054   
055                  return;
056              case SortableIterator::SORT_BY_TYPE:
057                  $format = '%HT';
058                  break;
059              case SortableIterator::SORT_BY_ACCESSED_TIME:
060                  $format = '%a';
061                  break;
062              case SortableIterator::SORT_BY_CHANGED_TIME:
063                  $format = '%c';
064                  break;
065              case SortableIterator::SORT_BY_MODIFIED_TIME:
066                  $format = '%m';
067                  break;
068              default:
069                  throw new \InvalidArgumentException(sprintf('Unknown sort options: %s.', $sort));
070          }
071   
072          $command
073              ->add('-print0 | xargs -0 stat -f')
074              ->arg($format.'%t%N')
075              ->add('| sort | cut -f 2');
076      }
077   
078      /**
079       * {@inheritdoc}
080       */
081      protected function buildFindCommand(Command $command, $dir)
082      {
083          parent::buildFindCommand($command, $dir)->addAtIndex('-E', 1);
084   
085          return $command;
086      }
087   
088      /**
089       * {@inheritdoc}
090       */
091      protected function buildContentFiltering(Command $command, array $contains, $not = false)
092      {
093          foreach ($contains as $contain) {
094              $expr = Expression::create($contain);
095   
096              // todo: avoid forking process for each $pattern by using multiple -e options
097              $command
098                  ->add('| grep -v \'^$\'')
099                  ->add('| xargs -I{} grep -I')
100                  ->add($expr->isCaseSensitive() ? null : '-i')
101                  ->add($not ? '-L' : '-l')
102                  ->add('-Ee')->arg($expr->renderPattern())
103                  ->add('{}')
104              ;
105          }
106      }
107  }
108