mirror of
https://github.com/adlawson/php-vfs.git
synced 2024-11-21 20:15:13 +00:00
Merge pull request #17 from atom-azimov/windows-support
Add windows support.
This commit is contained in:
commit
e955034419
1
.gitignore
vendored
1
.gitignore
vendored
@ -2,3 +2,4 @@
|
||||
composer.lock
|
||||
Vagrantfile
|
||||
vendor
|
||||
/.idea
|
||||
|
@ -23,6 +23,7 @@ class FileSystem implements FileSystemInterface
|
||||
protected $registry;
|
||||
protected $scheme;
|
||||
protected $wrapperClass;
|
||||
protected $root;
|
||||
|
||||
/**
|
||||
* @param string $scheme
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
@ -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) {
|
||||
|
@ -22,7 +22,7 @@ class AcceptanceTestCase extends TestCase
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
$this->fs = $this->buildFileSystem($this->wrapperClass);
|
||||
$this->fs = $this->buildFileSystem();
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
|
@ -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');
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user