Skip to content
This repository has been archived by the owner on Sep 20, 2021. It is now read-only.

Commit

Permalink
Auto-substream.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Hywan committed Oct 9, 2014
1 parent b275399 commit 0aeb7eb
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion Protocol/Vfs.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];



Expand Down Expand Up @@ -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) {

Expand All @@ -105,6 +117,8 @@ public function reach ( $queue = null ) {
break;
}

$this->_streams[$path] = $file;

return (string) $file;
}
}

0 comments on commit 0aeb7eb

Please sign in to comment.