diff --git a/.gitignore b/.gitignore index 99c2c31..7cb0708 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ composer.lock Vagrantfile vendor +/.idea diff --git a/src/FileSystem.php b/src/FileSystem.php index 44b2e1e..443414f 100644 --- a/src/FileSystem.php +++ b/src/FileSystem.php @@ -23,6 +23,7 @@ class FileSystem implements FileSystemInterface protected $registry; protected $scheme; protected $wrapperClass; + protected $root; /** * @param string $scheme diff --git a/src/Node/Directory.php b/src/Node/Directory.php index c7aa747..1aad35b 100644 --- a/src/Node/Directory.php +++ b/src/Node/Directory.php @@ -30,7 +30,7 @@ class Directory implements NodeContainerInterface */ public function __construct(array $nodes = []) { - $this->mode = self::TYPE_DIR | self::OTHER_FULL; + $this->mode = self::TYPE_DIR | self::OTHER_FULL | self::USER_FULL; $this->dateAccessed = new DateTime(); $this->dateCreated = $this->dateAccessed; diff --git a/src/Node/DirectoryLink.php b/src/Node/DirectoryLink.php index 43ad115..e4f8fe3 100644 --- a/src/Node/DirectoryLink.php +++ b/src/Node/DirectoryLink.php @@ -25,7 +25,7 @@ class DirectoryLink implements NodeContainerInterface, LinkInterface public function __construct(NodeContainerInterface $directory) { $this->directory = $directory; - $this->mode = self::TYPE_LINK | self::OTHER_FULL; + $this->mode = self::TYPE_LINK | self::OTHER_FULL | self::USER_FULL; $this->dateAccessed = new DateTime(); $this->dateCreated = clone $this->dateAccessed; diff --git a/src/Node/File.php b/src/Node/File.php index bc35c10..63556fb 100644 --- a/src/Node/File.php +++ b/src/Node/File.php @@ -25,7 +25,7 @@ class File implements FileInterface public function __construct($content = '') { $this->content = (string) $content; - $this->mode = self::TYPE_FILE | self::OTHER_FULL; + $this->mode = self::TYPE_FILE | self::OTHER_FULL | self::USER_FULL; $this->dateAccessed = new DateTime(); $this->dateCreated = clone $this->dateAccessed; diff --git a/src/Node/FileLink.php b/src/Node/FileLink.php index 7be6a79..b204565 100644 --- a/src/Node/FileLink.php +++ b/src/Node/FileLink.php @@ -25,7 +25,7 @@ class FileLink implements FileInterface, LinkInterface public function __construct(FileInterface $file) { $this->file = $file; - $this->mode = self::TYPE_LINK | self::OTHER_FULL; + $this->mode = self::TYPE_LINK | self::OTHER_FULL | self::USER_FULL; $this->dateAccessed = new DateTime(); $this->dateCreated = clone $this->dateAccessed; diff --git a/src/Node/Walker/NodeWalker.php b/src/Node/Walker/NodeWalker.php index f571821..c6f5c47 100644 --- a/src/Node/Walker/NodeWalker.php +++ b/src/Node/Walker/NodeWalker.php @@ -26,9 +26,6 @@ class NodeWalker implements NodeWalkerInterface public function findNode(NodeInterface $root, $path) { - $parts = $this->splitPath($path); - $node = $root; - return $this->walkPath($root, $path, function (NodeInterface $node, $name) { if (!$node instanceof NodeContainerInterface || !$node->has($name)) { return null; @@ -58,6 +55,8 @@ class NodeWalker implements NodeWalkerInterface */ protected function splitPath($path) { + $path = str_replace('/', DIRECTORY_SEPARATOR, $path); + return array_filter(explode($this->separator, $path)); } } diff --git a/src/Stream/DirectoryHandle.php b/src/Stream/DirectoryHandle.php index 2c44d28..94781bd 100644 --- a/src/Stream/DirectoryHandle.php +++ b/src/Stream/DirectoryHandle.php @@ -28,7 +28,7 @@ class DirectoryHandle extends AbstractHandle $parent = $this->fs->get($parentPath); if (!$parent && (boolean) $recursive) { - $parent = $this->buildNodesRecursive($this->fs->get('/'), $this->path); + $parent = $this->buildNodesRecursive($this->fs->get('/')); } if ($parent) { diff --git a/test/src/AcceptanceTestCase.php b/test/src/AcceptanceTestCase.php index e282d03..e58ba95 100644 --- a/test/src/AcceptanceTestCase.php +++ b/test/src/AcceptanceTestCase.php @@ -22,7 +22,7 @@ class AcceptanceTestCase extends TestCase public function setUp() { - $this->fs = $this->buildFileSystem($this->wrapperClass); + $this->fs = $this->buildFileSystem(); } public function tearDown() diff --git a/test/unit/Stream/DirectoryHandleTest.php b/test/unit/Stream/DirectoryHandleTest.php index 5e40632..2ee2f0d 100644 --- a/test/unit/Stream/DirectoryHandleTest.php +++ b/test/unit/Stream/DirectoryHandleTest.php @@ -45,7 +45,7 @@ class DirectoryHandleTest extends UnitTestCase ]); $this->fs->shouldReceive('get')->once()->with('/foo'); - $this->fs->shouldReceive('get')->times(2)->with('/'); + $this->fs->shouldReceive('get')->times(2)->with(DIRECTORY_SEPARATOR); $this->fs->shouldReceive('getLogger')->once()->withNoArgs()->andReturn($logger); $handle->rename('foo://bar'); diff --git a/test/unit/Stream/FileHandleTest.php b/test/unit/Stream/FileHandleTest.php index 60214bc..f214475 100644 --- a/test/unit/Stream/FileHandleTest.php +++ b/test/unit/Stream/FileHandleTest.php @@ -87,7 +87,7 @@ class FileHandleTest extends UnitTestCase ]); $this->fs->shouldReceive('get')->once()->with('/foo'); - $this->fs->shouldReceive('get')->times(2)->with('/'); + $this->fs->shouldReceive('get')->times(2)->with(DIRECTORY_SEPARATOR); $this->fs->shouldReceive('getLogger')->once()->withNoArgs()->andReturn($logger); $handle->rename('foo://bar'); @@ -290,7 +290,7 @@ class FileHandleTest extends UnitTestCase $root = Mockery::mock('Vfs\Node\NodeContainerInterface'); $root->shouldReceive('set')->once()->with('bar', $file); - $this->fs->shouldReceive('get')->once()->with('/')->andReturn($root); + $this->fs->shouldReceive('get')->once()->with(DIRECTORY_SEPARATOR)->andReturn($root); $this->fs->shouldReceive('get')->once()->with('/bar'); $this->fs->shouldReceive('getNodeFactory')->once()->withNoArgs()->andReturn($factory);