Page MenuHomePhabricator

D17455.id41977.diff
No OneTemporary

D17455.id41977.diff

diff --git a/src/filesystem/FileFinder.php b/src/filesystem/FileFinder.php
--- a/src/filesystem/FileFinder.php
+++ b/src/filesystem/FileFinder.php
@@ -250,9 +250,16 @@
$files = explode("\0", $stdout);
// On OSX/BSD, find prepends a './' to each file.
- for ($i = 0; $i < count($files); $i++) {
- if (substr($files[$i], 0, 2) == './') {
- $files[$i] = substr($files[$i], 2);
+ foreach ($files as $key => $file) {
+ // When matching directories, we can get "." back in the result set,
+ // but this isn't an interesting result.
+ if ($file == '.') {
+ unset($files[$key]);
+ continue;
+ }
+
+ if (substr($files[$key], 0, 2) == './') {
+ $files[$key] = substr($files[$key], 2);
}
}
}
diff --git a/src/filesystem/__tests__/FileFinderTestCase.php b/src/filesystem/__tests__/FileFinderTestCase.php
--- a/src/filesystem/__tests__/FileFinderTestCase.php
+++ b/src/filesystem/__tests__/FileFinderTestCase.php
@@ -76,7 +76,7 @@
}
}
- public function testFinderWithDirectories() {
+ public function testFinderWithFilesAndDirectories() {
foreach (array('php', 'shell') as $mode) {
$files = $this->getFinder()
->setGenerateChecksums(true)
@@ -104,6 +104,26 @@
}
}
+ public function testFinderWithDirectories() {
+ foreach (array('php', 'shell') as $mode) {
+ $directories = $this->getFinder()
+ ->withType('d')
+ ->setForceMode($mode)
+ ->find();
+
+ sort($directories);
+ $directories = array_values($directories);
+
+ $this->assertEqual(
+ array(
+ 'include_dir.txt',
+ 'include_dir.txt/subdir.txt',
+ ),
+ $directories,
+ pht('FileFinder of directories in "%s" mode', $mode));
+ }
+ }
+
public function testFinderWithPath() {
foreach (array('php', 'shell') as $mode) {
$files = $this->getFinder()

File Metadata

Mime Type
text/plain
Expires
Tue, Oct 22, 5:00 PM (2 w, 4 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6742376
Default Alt Text
D17455.id41977.diff (1 KB)

Event Timeline