Merge pull request #17 from atom-azimov/windows-support

Add windows support.
This commit is contained in:
Andrew Lawson 2016-02-20 12:46:01 +00:00
commit e955034419
11 changed files with 13 additions and 12 deletions

1
.gitignore vendored
View File

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

View File

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

View File

@ -30,7 +30,7 @@ class Directory implements NodeContainerInterface
*/ */
public function __construct(array $nodes = []) 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->dateAccessed = new DateTime();
$this->dateCreated = $this->dateAccessed; $this->dateCreated = $this->dateAccessed;

View File

@ -25,7 +25,7 @@ class DirectoryLink implements NodeContainerInterface, LinkInterface
public function __construct(NodeContainerInterface $directory) public function __construct(NodeContainerInterface $directory)
{ {
$this->directory = $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->dateAccessed = new DateTime();
$this->dateCreated = clone $this->dateAccessed; $this->dateCreated = clone $this->dateAccessed;

View File

@ -25,7 +25,7 @@ class File implements FileInterface
public function __construct($content = '') public function __construct($content = '')
{ {
$this->content = (string) $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->dateAccessed = new DateTime();
$this->dateCreated = clone $this->dateAccessed; $this->dateCreated = clone $this->dateAccessed;

View File

@ -25,7 +25,7 @@ class FileLink implements FileInterface, LinkInterface
public function __construct(FileInterface $file) public function __construct(FileInterface $file)
{ {
$this->file = $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->dateAccessed = new DateTime();
$this->dateCreated = clone $this->dateAccessed; $this->dateCreated = clone $this->dateAccessed;

View File

@ -26,9 +26,6 @@ class NodeWalker implements NodeWalkerInterface
public function findNode(NodeInterface $root, $path) public function findNode(NodeInterface $root, $path)
{ {
$parts = $this->splitPath($path);
$node = $root;
return $this->walkPath($root, $path, function (NodeInterface $node, $name) { return $this->walkPath($root, $path, function (NodeInterface $node, $name) {
if (!$node instanceof NodeContainerInterface || !$node->has($name)) { if (!$node instanceof NodeContainerInterface || !$node->has($name)) {
return null; return null;
@ -58,6 +55,8 @@ class NodeWalker implements NodeWalkerInterface
*/ */
protected function splitPath($path) protected function splitPath($path)
{ {
$path = str_replace('/', DIRECTORY_SEPARATOR, $path);
return array_filter(explode($this->separator, $path)); return array_filter(explode($this->separator, $path));
} }
} }

View File

@ -28,7 +28,7 @@ class DirectoryHandle extends AbstractHandle
$parent = $this->fs->get($parentPath); $parent = $this->fs->get($parentPath);
if (!$parent && (boolean) $recursive) { if (!$parent && (boolean) $recursive) {
$parent = $this->buildNodesRecursive($this->fs->get('/'), $this->path); $parent = $this->buildNodesRecursive($this->fs->get('/'));
} }
if ($parent) { if ($parent) {

View File

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

View File

@ -45,7 +45,7 @@ class DirectoryHandleTest extends UnitTestCase
]); ]);
$this->fs->shouldReceive('get')->once()->with('/foo'); $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); $this->fs->shouldReceive('getLogger')->once()->withNoArgs()->andReturn($logger);
$handle->rename('foo://bar'); $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')->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); $this->fs->shouldReceive('getLogger')->once()->withNoArgs()->andReturn($logger);
$handle->rename('foo://bar'); $handle->rename('foo://bar');
@ -290,7 +290,7 @@ class FileHandleTest extends UnitTestCase
$root = Mockery::mock('Vfs\Node\NodeContainerInterface'); $root = Mockery::mock('Vfs\Node\NodeContainerInterface');
$root->shouldReceive('set')->once()->with('bar', $file); $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('get')->once()->with('/bar');
$this->fs->shouldReceive('getNodeFactory')->once()->withNoArgs()->andReturn($factory); $this->fs->shouldReceive('getNodeFactory')->once()->withNoArgs()->andReturn($factory);