Fix directory reading. Return FALSE on directory end instead empty string for avoiding infinity readdir cycles.

This commit is contained in:
Yuriy Vilks 2016-04-21 19:51:54 +00:00
parent e955034419
commit 70876cd1fa
2 changed files with 25 additions and 0 deletions

View File

@ -84,6 +84,8 @@ class DirectoryHandle extends AbstractHandle
return $name;
}
}
return false;
}
public function write($content)

View File

@ -0,0 +1,23 @@
<?php
namespace Vfs\Stream\StreamWrapper;
use Vfs\Test\AcceptanceTestCase;
class ReadDirAcceptanceTest extends AcceptanceTestCase
{
protected $tree = [
'foo' => [
'bar' => 'baz'
]
];
public function testReadDirectory()
{
$dHandler = opendir("$this->scheme:///foo");
$expects = ['bar' => true, '.' => true, '..' => true];
while(($file = readdir($dHandler)) !== false) {
$this->assertArrayHasKey($file, $expects);
}
}
}