[Finder] Fix the BSD adapter
This commit is contained in:
parent
24012743b8
commit
b5506777ea
@ -53,13 +53,7 @@ abstract class AbstractFindAdapter extends AbstractAdapter
|
||||
}
|
||||
|
||||
$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');
|
||||
@ -129,6 +123,20 @@ abstract class AbstractFindAdapter extends AbstractAdapter
|
||||
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
|
||||
|
@ -48,4 +48,12 @@ class GnuFindAdapter extends AbstractFindAdapter
|
||||
$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');
|
||||
}
|
||||
}
|
||||
|
@ -202,7 +202,7 @@ class FinderTest extends Iterator\RealIteratorTestCase
|
||||
$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());
|
||||
|
||||
|
Reference in New Issue
Block a user