8000 [Finder] Adds bsd adapter. by jfsimon · Pull Request #5876 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Finder] Adds bsd adapter. #5876

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

Merged
merged 2 commits into from
Nov 1, 2012
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
[Finder] Fix the BSD adapter
  • Loading branch information
Dinduks authored and jfsimon committed Nov 1, 2012
commit b5506777ea7c42894bbe2d0fcbc39cc62d97b91b
22 changes: 15 additions & 7 deletions src/Symfony/Component/Finder/Adapter/AbstractFindAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,7 @@ public function searchInDirectory($dir)
}

$command = Command::create();

$find = $command
->ins('find')
->add('find ')
->arg($dir)
->add('-noleaf') // -noleaf option is required for filesystems who doesn't follow '.' and '..' convention
->add('-regextype posix-extended');
$find = $this->buildFindCommand($command, $dir);

if ($this->followLinks) {
$find->add('-follow');
Expand Down Expand Up @@ -129,6 +123,20 @@ public function isSupported()
return $this->shell->testCommand('find');
}

/**
* @param Command $command
*
* @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
}

/**
* @param Command $command
* @param string[] $names
Expand Down
8 changes: 8 additions & 0 deletions src/Symfony/Component/Finder/Adapter/GnuFindAdapter.php
< 8000 td id="diff-1daa3b2662e3b1c7ea761fda7475f88ec21c817141ccd6c27f115bdd23d9ececR49" data-line-number="49" class="blob-num blob-num-context js-linkable-line-number js-blob-rnum">
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,12 @@ protected function buildFormatSorting(Command $command, $format)
$command->get('find')->add('-printf')->arg($format.' %h/%f\\n')
->add('| sort | cut')->arg('-d ')->arg('-f2-');
}

/**
* {@inheritdoc}
*/
protected function buildFindCommand(Command $command, $dir)
{
return parent::buildFindCommand($command, $dir)->add('-regextype posix-extended');
}
}
2 changes: 1 addition & 1 deletion src/Symfony/Component/Finder/Tests/FinderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ public function testIgnoreDotFiles($adapter)
$this->assertSame($finder, $finder->ignoreDotFiles(false)->ignoreVCS(false));
$this->assertIterator($this->toAbsolute(array('.git', '.bar', '.foo', '.foo/.bar', 'foo', 'foo/bar.tmp', 'test.php', 'test.py', 'toto', 'foo bar')), $finder->in(self::$tmpDir)->getIterator());

$finder = new Finder();
$finder = $this->buildFinder($adapter);
$finder->ignoreDotFiles(false)->ignoreDotFiles(false)->ignoreVCS(false);
$this->assertIterator($this->toAbsolute(array('.git', '.bar', '.foo', '.foo/.bar', 'foo', 'foo/bar.tmp', 'test.php', 'test.py', 'toto', 'foo bar')), $finder->in(self::$tmpDir)->getIterator());

Expand Down
0