Skip to content

[2.2] [WIP] [Finder] Adding native finders implementations #4061

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 37 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
331e3ad
[Finder] Added adapter interface.
jfsimon Apr 21, 2012
a05f449
[Finder] Added abstract adapter.
jfsimon Apr 21, 2012
d340849
[Finder] Moved current implementation to php adapter.
jfsimon Apr 21, 2012
c3cdda3
[Finder] Moved min/max depth calculation to abstract adapter.
jfsimon Apr 21, 2012
411cb8b
[Finder] Fixed depth iterator tests.
jfsimon Apr 21, 2012
c47c5de
[Finder] Moved glob/regex methods to new Expr class.
jfsimon Apr 22, 2012
432a3fe
[Finder] Added Expr class tests.
jfsimon Apr 22, 2012
524ebe9
[Finder] Added file paths iterator and its tests.
jfsimon Apr 22, 2012
f6acae0
[Finder] Added minimalist gnu find adapter.
jfsimon Apr 22, 2012
de2ae38
[Finder] Added adapter validity control.
jfsimon Apr 22, 2012
dc4bf1f
[Finder] Added adapter selection method.
jfsimon Apr 22, 2012
c23ebf9
[Finder] Updated tests to use all valid adapters.
jfsimon Apr 22, 2012
bf74c89
[Finder] Added native names/notNames support to gnu find adapter.
jfsimon Apr 22, 2012
7b593ee
[Finder] Added native sizes support to gnu find adapter.
jfsimon Apr 22, 2012
3b3ee8f
[Finder] Added native dates support to gnu find adapter.
jfsimon Apr 22, 2012
530f229
[Finder] Performed some cleanup.
jfsimon Apr 22, 2012
05897a4
[Finder] Improved command class.
jfsimon Apr 22, 2012
da79cc4
[Finder] Refactored command building.
jfsimon Apr 23, 2012
19f055e
[Finder] Updated shell command test.
jfsimon Apr 23, 2012
daa9b31
[Finder] Added adapter registration method.
jfsimon Apr 23, 2012
cba5bca
[Finder] Cleaned code.
jfsimon Apr 24, 2012
f131e27
[Finder] Added possibility for adapter to fail.
Apr 24, 2012
8a3b2de
[Finder] Added adapters registration tests.
Apr 24, 2012
eefba16
[Finder] Added grep support for gnu find adapter.
May 10, 2012
924561c
[Finder] Fixed typo & removed debug output.
jfsimon Jul 4, 2012
f924d85
[Finder] Added native sorting support to gnu find adapter.
jfsimon Jul 10, 2012
4229962
[Finder] Refactored expression (regex/glob) handling.
jfsimon Jul 31, 2012
e80e115
[Finder] Added expression tests & fixed related bugs.
jfsimon Aug 1, 2012
8b9ffc6
[Finder] Moved Shell & Command classes to Shell namespace.
jfsimon Aug 1, 2012
0e61db9
[Finder] Fixed regex escaped flag/joker bug.
jfsimon Aug 1, 2012
60e69fe
[Finder] Fixed 'regex are not search' problem.
jfsimon Aug 1, 2012
4e3b017
[Finder] Fixed master rebase.
jfsimon Aug 1, 2012
144c61b
[Finder] Fixed search directory.
jfsimon Aug 1, 2012
aa84e2d
[Finder] Fixed typos, CS and small errors.
jfsimon Aug 1, 2012
46cc2d4
[Finder] Fixed namespace.
jfsimon Aug 2, 2012
5fc01f2
[Finder] Changed method name for gnu find adapter.
jfsimon Aug 2, 2012
ef0ebb8
[Finder] Fixed gnu find regex name filtering problems.
jfsimon Aug 3, 2012
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[Finder] Changed method name for gnu find adapter.
  • Loading branch information
jfsimon committed Aug 2, 2012
commit 5fc01f257b64057f1f8f526187ba09e9fe857c37
25 changes: 13 additions & 12 deletions src/Symfony/Component/Finder/Adapter/GnuFindAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,22 +78,22 @@ public function searchInDirectory($dir)
$find->add('-type f');
}

$this->buildNamesCommand($find, $this->names);
$this->buildNamesCommand($find, $this->notNames, true);
$this->buildSizesCommand($find, $this->sizes);
$this->buildDatesCommand($find, $this->dates);
$this->buildNamesFiltering($find, $this->names);
$this->buildNamesFiltering($find, $this->notNames, true);
$this->buildSizesFiltering($find, $this->sizes);
$this->buildDatesFiltering($find, $this->dates);

$useGrep = $this->shell->testCommand('grep') && $this->shell->testCommand('xargs');
$useSort = is_int($this->sort) && $this->shell->testCommand('sort') && $this->shell->testCommand('awk');

if ($useGrep && ($this->contains || $this->notContains)) {
$grep = $command->ins('grep');
$this->buildContainsCommand($grep, $this->contains);
$this->buildContainsCommand($grep, $this->notContains, true);
$this->buildContentFiltering($grep, $this->contains);
$this->buildContentFiltering($grep, $this->notContains, true);
}

if ($useSort) {
$this->buildSortCommand($command, $this->sort);
$this->buildSorting($command, $this->sort);
}

$paths = $this->shell->testCommand('uniq') ? $command->add('| uniq')->execute() : array_unique($command->execute());
Expand Down Expand Up @@ -141,7 +141,7 @@ public function getName()
* @param string[] $names
* @param bool $not
*/
private function buildNamesCommand(Command $command, array $names, $not = false)
private function buildNamesFiltering(Command $command, array $names, $not = false)
{
if (0 === count($names)) {
return;
Expand Down Expand Up @@ -178,7 +178,7 @@ private function buildNamesCommand(Command $command, array $names, $not = false)
* @param Command $command
* @param NumberComparator[] $sizes
*/
private function buildSizesCommand(Command $command, array $sizes)
private function buildSizesFiltering(Command $command, array $sizes)
{
foreach ($sizes as $i => $size) {
$command->add($i > 0 ? '-and' : null);
Expand Down Expand Up @@ -217,7 +217,7 @@ private function buildSizesCommand(Command $command, array $sizes)
* @param Command $command
* @param DateComparator[] $dates
*/
private function buildDatesCommand(Command $command, array $dates)
private function buildDatesFiltering(Command $command, array $dates)
{
foreach ($dates as $i => $date) {
$command->add($i > 0 ? '-and' : null);
Expand Down Expand Up @@ -265,11 +265,12 @@ private function buildDatesCommand(Command $command, array $dates)
* @param array $contains
* @param bool $not
*/
private function buildContainsCommand(Command $command, array $contains, $not = false)
private function buildContentFiltering(Command $command, array $contains, $not = false)
{
foreach ($contains as $contain) {
$expr = Expression::create($contain);

// todo: avoid forking process for each $pattern by using multiple -e options
$command
->add('| xargs -r grep -I')
->add($expr->isCaseSensitive() ? null : '-i')
Expand All @@ -278,7 +279,7 @@ private function buildContainsCommand(Command $command, array $contains, $not =
}
}

private function buildSortCommand(Command $command, $sort)
private function buildSorting(Command $command, $sort)
{
switch ($sort) {
case SortableIterator::SORT_BY_NAME:
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy