mirror of
https://github.com/adlawson/php-vfs.git
synced 2024-11-21 20:15:13 +00:00
Add windows support.
This commit is contained in:
parent
75e2fde9b7
commit
3995f84e8c
1
.gitignore
vendored
1
.gitignore
vendored
@ -2,3 +2,4 @@
|
|||||||
composer.lock
|
composer.lock
|
||||||
Vagrantfile
|
Vagrantfile
|
||||||
vendor
|
vendor
|
||||||
|
/.idea
|
||||||
|
@ -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
|
||||||
|
@ -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;
|
||||||
|
@ -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;
|
||||||
|
@ -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;
|
||||||
|
@ -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;
|
||||||
|
@ -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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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) {
|
||||||
|
@ -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()
|
||||||
|
@ -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');
|
||||||
|
@ -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);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user