/**
     * {@inheritdoc}
     */
    protected function buildFormatSorting(Command $command, $sort)
    {
        switch ($sort) {
            case SortableIterator::SORT_BY_NAME:
                $command->ins('sort')->add('| sort');

                return;
            case SortableIterator::SORT_BY_TYPE:
                $format = '%HT';
                break;
            case SortableIterator::SORT_BY_ACCESSED_TIME:
                $format = '%a';
                break;
            case SortableIterator::SORT_BY_CHANGED_TIME:
                $format = '%c';
                break;
            case SortableIterator::SORT_BY_MODIFIED_TIME:
                $format = '%m';
                break;
            default:
                throw new \InvalidArgumentException('Unknown sort options: '.$sort.'.');
        }

        $command
            ->add('-print0 | xargs -0 stat -f')
            ->arg($format.'%t%N')
            ->add('| sort | cut -f 2');
    }
    /**
     * {@inheritdoc}
     */
    protected function buildFormatSorting(Command $command, $sort)
    {
        switch ($sort) {
            case SortableIterator::SORT_BY_NAME:
                $command->ins('sort')->add('| sort');

                return;
            case SortableIterator::SORT_BY_TYPE:
                $format = '%y';
                break;
            case SortableIterator::SORT_BY_ACCESSED_TIME:
                $format = '%A@';
                break;
            case SortableIterator::SORT_BY_CHANGED_TIME:
                $format = '%C@';
                break;
            case SortableIterator::SORT_BY_MODIFIED_TIME:
                $format = '%T@';
                break;
            default:
                throw new \InvalidArgumentException('Unknown sort options: '.$sort.'.');
        }

        $command
            ->get('find')
            ->add('-printf')
            ->arg($format.' %h/%f\\n')
            ->add('| sort | cut')
            ->arg('-d ')
            ->arg('-f2-')
        ;
    }
예제 #3
0
 protected function buildFindCommand(Command $command, $dir)
 {
     return $command->ins('find')->add('find ')->arg($dir)->add('-noleaf');
 }
 /**
  * @param Command $command
  * @param string  $dir
  *
  * @return Command
  */
 protected function buildFindCommand(Command $command, $dir)
 {
     return $command->ins('find')->add('find ')->arg($dir)->add('-noleaf');
     // the -noleaf option is required for filesystems that don't follow the '.' and '..' conventions
 }
예제 #5
0
    private function buildSorting(Command $command, $sort)
    {
        switch ($sort) {
            case SortableIterator::SORT_BY_NAME:
                $format = null;
                break;
            case SortableIterator::SORT_BY_TYPE:
                $format = '%y';
                break;
            case SortableIterator::SORT_BY_ACCESSED_TIME:
                $format = '%A@';
                break;
            case SortableIterator::SORT_BY_CHANGED_TIME:
                $format = '%C@';
                break;
            case SortableIterator::SORT_BY_MODIFIED_TIME:
                $format = '%T@';
                break;
            default:
                throw new \InvalidArgumentException('Unknown sort options: '.$sort.'.');
        }

        $command->get('find')->add('-printf')->arg($format.' %h/%f\\n');
        $command->ins('sort')->add('| sort');
        $command->ins('awk')->add('| awk')->arg('{ print $'.(null === $format ? '1' : '2').' }');
    }
예제 #6
0
 /**
  * @param Command $command
  * @param string  $sort
  *
  * @throws \InvalidArgumentException
  */
 private function buildSorting(Command $command, $sort)
 {
     switch ($sort) {
         case SortableIterator::SORT_BY_NAME:
             $command->ins('sort')->add('| sort');
             return;
         case SortableIterator::SORT_BY_TYPE:
             $format = '%y';
             break;
         case SortableIterator::SORT_BY_ACCESSED_TIME:
             $format = '%A@';
             break;
         case SortableIterator::SORT_BY_CHANGED_TIME:
             $format = '%C@';
             break;
         case SortableIterator::SORT_BY_MODIFIED_TIME:
             $format = '%T@';
             break;
         default:
             throw new \InvalidArgumentException('Unknown sort options: ' . $sort . '.');
     }
     $this->buildFormatSorting($command, $format);
 }