Skip to content

Commit b550677

Browse files
Dinduksjfsimon
authored andcommitted
[Finder] Fix the BSD adapter
1 parent 2401274 commit b550677

File tree

3 files changed

+24
-8
lines changed

3 files changed

+24
-8
lines changed

src/Symfony/Component/Finder/Adapter/AbstractFindAdapter.php

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,7 @@ public function searchInDirectory($dir)
5353
}
5454

5555
$command = Command::create();
56-
57-
$find = $command
58-
->ins('find')
59-
->add('find ')
60-
->arg($dir)
61-
->add('-noleaf') // -noleaf option is required for filesystems who doesn't follow '.' and '..' convention
62-
->add('-regextype posix-extended');
56+
$find = $this->buildFindCommand($command, $dir);
6357

6458
if ($this->followLinks) {
6559
$find->add('-follow');
@@ -129,6 +123,20 @@ public function isSupported()
129123
return $this->shell->testCommand('find');
130124
}
131125

126+
/**
127+
* @param Command $command
128+
*
129+
* @return Command
130+
*/
131+
protected function buildFindCommand(Command $command, $dir)
132+
{
133+
return $command
134+
->ins('find')
135+
->add('find ')
136+
->arg($dir)
137+
->add('-noleaf'); // the -noleaf option is required for filesystems that don't follow the '.' and '..' conventions
138+
}
139+
132140
/**
133141
* @param Command $command
134142
* @param string[] $names

src/Symfony/Component/Finder/Adapter/GnuFindAdapter.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,12 @@ protected function buildFormatSorting(Command $command, $format)
4848
$command->get('find')->add('-printf')->arg($format.' %h/%f\\n')
4949
->add('| sort | cut')->arg('-d ')->arg('-f2-');
5050
}
51+
52+
/**
53+
* {@inheritdoc}
54+
*/
55+
protected function buildFindCommand(Command $command, $dir)
56+
{
57+
return parent::buildFindCommand($command, $dir)->add('-regextype posix-extended');
58+
}
5159
}

src/Symfony/Component/Finder/Tests/FinderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ public function testIgnoreDotFiles($adapter)
202202
$this->assertSame($finder, $finder->ignoreDotFiles(false)->ignoreVCS(false));
203203
$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());
204204

205-
$finder = new Finder();
205+
$finder = $this->buildFinder($adapter);
206206
$finder->ignoreDotFiles(false)->ignoreDotFiles(false)->ignoreVCS(false);
207207
$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());
208208

0 commit comments

Comments
 (0)