From 0aeb7eb523a901b8ca278110211d6c69d1427aec Mon Sep 17 00:00:00 2001 From: Ivan Enderlin Date: Fri, 10 Oct 2014 00:36:09 +0200 Subject: [PATCH] Auto-substream. Detect if a stream has a parent, and if yes, automatically create a substream. Example: to create Root/ A Aa Aaa B/ Foo Bar all we have to do is to resolve the following paths: hoa://Test/Vfs/Root?type=directory hoa://Test/Vfs/Root/A hoa://Test/Vfs/Root/Aa hoa://Test/Vfs/Root/Aaa hoa://Test/Vfs/Root/B?type=directory hoa://Test/Vfs/Root/B/Foo hoa://Test/Vfs/Root/B/Bar --- Protocol/Vfs.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/Protocol/Vfs.php b/Protocol/Vfs.php index ddfa2e6..92f5987 100644 --- a/Protocol/Vfs.php +++ b/Protocol/Vfs.php @@ -56,7 +56,14 @@ class Vfs extends Core\Protocol { * * @var \Hoa\Core\Protocol string */ - protected $_name = 'Vfs'; + protected $_name = 'Vfs'; + + /** + * Current opened streams. + * + * @var \Hoa\Test\Protocol\Vfs array + */ + protected $_streams = []; @@ -90,6 +97,11 @@ public function reach ( $queue = null ) { else $file = atoum\mock\streams\fs\file::get($path); + $parentDirectory = dirname($path); + + if(isset($this->_streams[$parentDirectory])) + $this->_streams[$parentDirectory]->dir_readdir[] = $file; + foreach($queries as $query => $value) switch($query) { @@ -105,6 +117,8 @@ public function reach ( $queue = null ) { break; } + $this->_streams[$path] = $file; + return (string) $file; } }