Skip to content

Commit

Permalink
[Finder] Fix the BSD adapter
Browse files Browse the repository at this point in the history
  • Loading branch information
Dinduks authored and jfsimon committed Nov 1, 2012
1 parent 2401274 commit b550677
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 8 deletions.
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
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 comments on commit b550677

Please sign in to comment.