Add windows support.

This commit is contained in:
Elbek Azimov 2016-02-20 03:49:02 +05:00
parent 75e2fde9b7
commit 3995f84e8c
11 changed files with 13 additions and 12 deletions

1
.gitignore vendored
View File

@ -2,3 +2,4 @@
composer.lock
Vagrantfile
vendor
/.idea

View File

@ -23,6 +23,7 @@ class FileSystem implements FileSystemInterface
protected $registry;
protected $scheme;
protected $wrapperClass;
protected $root;
/**
* @param string $scheme

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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));
}
}

View File

@ -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) {

View File

@ -22,7 +22,7 @@ class AcceptanceTestCase extends TestCase
public function setUp()
{
$this->fs = $this->buildFileSystem($this->wrapperClass);
$this->fs = $this->buildFileSystem();
}
public function tearDown()

View File

@ -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');

View File

@ -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);