Drupal 8.0.0 beta 12. More info: https://www.drupal.org/node/2514176
This commit is contained in:
commit
9921556621
13277 changed files with 1459781 additions and 0 deletions
192
core/vendor/mikey179/vfsStream/CHANGELOG.md
vendored
Normal file
192
core/vendor/mikey179/vfsStream/CHANGELOG.md
vendored
Normal file
|
@ -0,0 +1,192 @@
|
|||
1.5.0 (2015-03-29)
|
||||
------------------
|
||||
|
||||
* implemented #91: `vfsStream::copyFromFileSystem()` should create large file instances
|
||||
* implemented #92: `vfsStream::copyFromFileSystem()` should respect block devices
|
||||
* fixed #107: `touch()` does not respect file permissions
|
||||
* fixed #105: vfs directory structure is not reset after each test
|
||||
* fixed #104: vfsStream can't handle url encoded pathes
|
||||
|
||||
|
||||
1.4.0 (2014-09-14)
|
||||
------------------
|
||||
|
||||
* implemented #85: Added support for emulating block devices in the virtual filesystem, feature provided by Harris Borawski
|
||||
* fixed #68: Unlink a non-existing file now triggers a PHP warning
|
||||
|
||||
|
||||
1.3.0 (2014-07-21)
|
||||
------------------
|
||||
|
||||
* implemented #79: possibility to mock large files without large memory footprint, see https://github.com/mikey179/vfsStream/wiki/MockingLargeFiles
|
||||
* implemented #67: added partial support for text-mode translation flag (i.e., no actual translation of line endings takes place) so it no longer throws an exception (provided by Anthon Pang)
|
||||
* fixed issue #74: issue with trailing windows path separators (provided by Sebastian Krüger)
|
||||
* fixed issue #50: difference between real file system and vfs with `RecursiveDirectoryIterator`
|
||||
* fixed issue #80: touch with no arguments for modification and access time behave incorrect
|
||||
* deprecated `org\bovigo\vfs\vfsStreamFile::readUntilEnd()`
|
||||
* deprecated `org\bovigo\vfs\vfsStreamFile::getBytesRead()`
|
||||
|
||||
|
||||
1.2.0 (2013-04-01)
|
||||
------------------
|
||||
|
||||
* implemented issue #34: provide `url()` method on all `vfsStreamContent` instances
|
||||
* added `org\bovigo\vfs\vfsStreamContent::url()`
|
||||
* added `org\bovigo\vfs\vfsStreamContent::path()`
|
||||
* fixed issue #40: flock implementation doesn't work correctly, patch provided by Kamil Dziedzic
|
||||
* fixed issue #49: call to member function on a non-object when trying to delete a file one above root where a file with same name in root exists
|
||||
* fixed issue #51: `unlink()` must consider permissions of directory where file is inside, not of the file to unlink itself
|
||||
* fixed issue #52: `chmod()`, `chown()` and `chgrp()` must consider permissions of directory where file/directory is inside
|
||||
* fixed issue #53: `chmod()`, `chown()` and `chgrp()` must consider current user and current owner of file/directoy to change
|
||||
|
||||
|
||||
1.1.0 (2012-08-25)
|
||||
------------------
|
||||
|
||||
* implemented issue #11: add support for `streamWrapper::stream_metadata()` vfsStream now supports `touch()`, `chown()`, `chgrp()` and `chmod()`
|
||||
* implemented issue #33: add support for `stream_truncate()` (provided by https://github.com/nikcorg)
|
||||
* implemented issue #35: size limit (quota) for VFS
|
||||
|
||||
|
||||
1.0.0 (2012-05-15)
|
||||
------------------
|
||||
|
||||
* raised requirement for PHP version to 5.3.0
|
||||
* migrated codebase to use namespaces
|
||||
* changed distribution from PEAR to Composer
|
||||
* implemented issue #30: support "c" mode for `fopen()`
|
||||
* fixed issue #31: prohibit aquiring locks when already locked / release lock on `fclose()`
|
||||
* fixed issue #32: problems when subfolder has same name as folder
|
||||
* fixed issue #36: `vfsStreamWrapper::stream_open()` should return false while trying to open existing non-writable file, patch provided by Alexander Peresypkin
|
||||
|
||||
|
||||
0.11.2 (2012-01-14)
|
||||
-------------------
|
||||
|
||||
* fixed issue #29: set permissions properly when using `vfsStream::copyFromFileSystem()`, patch provided by predakanga
|
||||
* fixed failing tests under PHP > 5.3.2
|
||||
|
||||
|
||||
0.11.1 (2011-12-04)
|
||||
-------------------
|
||||
|
||||
* fixed issue #28: `mkdir()` overwrites existing directories/files
|
||||
|
||||
|
||||
0.11.0 (2011-11-29)
|
||||
-------------------
|
||||
|
||||
* implemented issue #20: `vfsStream::create()` removes old structure
|
||||
* implemented issue #4: possibility to copy structure from existing file system
|
||||
* fixed issue #23: `unlink()` should not remove any directory
|
||||
* fixed issue #25: `vfsStreamDirectory::hasChild()` gives false positives for nested paths, patch provided by Andrew Coulton
|
||||
* fixed issue #26: opening a file for reading only should not update its modification time, reported and initial patch provided by Ludovic Chabant
|
||||
|
||||
|
||||
0.10.1 (2011-08-22)
|
||||
-------------------
|
||||
|
||||
* fixed issue #16: replace `vfsStreamContent` to `vfsStreamContainer` for autocompletion
|
||||
* fixed issue #17: `vfsStream::create()` has issues with numeric directories, patch provided by mathieuk
|
||||
|
||||
|
||||
0.10.0 (2011-07-22)
|
||||
-------------------
|
||||
|
||||
* added new method `vfsStreamContainer::hasChildren()` and `vfsStreamDirectory::hasChildren()`
|
||||
* implemented issue #14: less verbose way to initialize vfsStream
|
||||
* implemented issue #13: remove deprecated method `vfsStreamContent::setFilemtime()`
|
||||
* implemented issue #6: locking meachanism for files
|
||||
* ensured that `stream_set_blocking()`, `stream_set_timeout()` and `stream_set_write_buffer()` on vfsStream urls have the same behaviour with PHP 5.2 and 5.3
|
||||
* implemented issue #10: method to print directory structure
|
||||
|
||||
|
||||
0.9.0 (2011-07-13)
|
||||
------------------
|
||||
|
||||
* implemented feature request issue #7: add support for `fileatime()` and `filectime()`
|
||||
* fixed issue #3: add support for `streamWrapper::stream_cast()`
|
||||
* fixed issue #9: resolve path not called everywhere its needed
|
||||
* deprecated `vfsStreamAbstractContent::setFilemtime()`, use `vfsStreamAbstractContent::lastModified()` instead, will be removed with 0.10.0
|
||||
|
||||
|
||||
0.8.0 (2010-10-08)
|
||||
------------------
|
||||
|
||||
* implemented enhancement #6: use `vfsStream::umask()` to influence initial file mode for files and directories
|
||||
* implemented enhancement #19: support of .. in the url, patch provided by Guislain Duthieuw
|
||||
* fixed issue #18: `getChild()` returns NULL when child's name contains parent name
|
||||
* fixed bug with incomplete error message when accessing non-existing files on root level
|
||||
|
||||
|
||||
0.7.0 (2010-06-08)
|
||||
------------------
|
||||
|
||||
* added new `vfsStream::setup()` method to simplify vfsStream usage
|
||||
* fixed issue #15: `mkdir()` creates a subfolder in a folder without permissions
|
||||
|
||||
|
||||
0.6.0 (2010-02-15)
|
||||
------------------
|
||||
|
||||
* added support for `$mode` param when opening files, implements enhancement #7 and fixes issue #13
|
||||
* `vfsStreamWrapper::stream_open()` now evaluates `$options` for `STREAM_REPORT_ERRORS`
|
||||
|
||||
|
||||
0.5.0 (2010-01-25)
|
||||
------------------
|
||||
|
||||
* added support for `rename()`, patch provided by Benoit Aubuchon
|
||||
* added support for . as directory alias so that `vfs://foo/.` resolves to `vfs://foo`, can be used as workaround for bug #8
|
||||
|
||||
|
||||
0.4.0 (2009-07-13)
|
||||
------------------
|
||||
|
||||
* added support for file modes, users and groups (with restrictions, see http://code.google.com/p/bovigo/wiki/vfsStreamDocsKnownIssues)
|
||||
* fixed bug #5: `vfsStreamDirectory::addChild()` does not replace child with same name
|
||||
* fixed bug with `is_writable()` because of missing `stat()` fields, patch provided by Sergey Galkin
|
||||
|
||||
|
||||
0.3.2 (2009-02-16)
|
||||
------------------
|
||||
|
||||
* support trailing slashes on directories in vfsStream urls, patch provided by Gabriel Birke
|
||||
* fixed bug #4: vfsstream can only be read once, reported by Christoph Bloemer
|
||||
* enabled multiple iterations at the same time over the same directory
|
||||
|
||||
|
||||
0.3.1 (2008-02-18)
|
||||
------------------
|
||||
|
||||
* fixed path/directory separator issues under linux systems
|
||||
* fixed uid/gid issues under linux systems
|
||||
|
||||
|
||||
0.3.0 (2008-01-02)
|
||||
------------------
|
||||
|
||||
* added support for `rmdir()`
|
||||
* added `vfsStream::newDirectory()`, dropped `vfsStreamDirectory::ceate()`
|
||||
* added new interface `vfsStreamContainer`
|
||||
* added `vfsStreamContent::at()` which allows code like `$file = vfsStream::newFile('file.txt.')->withContent('foo')->at($otherDir);`
|
||||
* added `vfsStreamContent::lastModified()`, made `vfsStreamContent::setFilemtime()` an alias for this
|
||||
* moved from Stubbles development environment to bovigo
|
||||
* refactorings to reduce crap index of various methods
|
||||
|
||||
|
||||
0.2.0 (2007-12-29)
|
||||
------------------
|
||||
|
||||
* moved `vfsStreamWrapper::PROTOCOL` to `vfsStream::SCHEME`
|
||||
* added new `vfsStream::url()` method to assist in creating correct vfsStream urls
|
||||
* added `vfsStream::path()` method as opposite to `vfsStream::url()`
|
||||
* a call to `vfsStreamWrapper::register()` will now reset the root to null, implemented on request from David Zuelke
|
||||
* added support for `is_readable()`, `is_dir()`, `is_file()`
|
||||
* added `vfsStream::newFile()` to be able to do `$file = vfsStream::newFile("foo.txt")->withContent("bar");`
|
||||
|
||||
|
||||
0.1.0 (2007-12-14)
|
||||
------------------
|
||||
|
||||
* Initial release.
|
27
core/vendor/mikey179/vfsStream/LICENSE
vendored
Normal file
27
core/vendor/mikey179/vfsStream/LICENSE
vendored
Normal file
|
@ -0,0 +1,27 @@
|
|||
Copyright (c) 2007-2015, Frank Kleine
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of Stubbles nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
|
||||
OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
33
core/vendor/mikey179/vfsStream/composer.json
vendored
Normal file
33
core/vendor/mikey179/vfsStream/composer.json
vendored
Normal file
|
@ -0,0 +1,33 @@
|
|||
{
|
||||
"name": "mikey179/vfsStream",
|
||||
"type": "library",
|
||||
"homepage": "http://vfs.bovigo.org/",
|
||||
"description": "Virtual file system to mock the real file system in unit tests.",
|
||||
"license": "BSD-3-Clause",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Frank Kleine",
|
||||
"homepage": "http://frankkleine.de/",
|
||||
"role": "Developer"
|
||||
}
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/mikey179/vfsStream/issues",
|
||||
"source": "https://github.com/mikey179/vfsStream/tree/master",
|
||||
"wiki": "https://github.com/mikey179/vfsStream/wiki"
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "~4.5"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-0": { "org\\bovigo\\vfs\\": "src/main/php" }
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.5.x-dev"
|
||||
}
|
||||
}
|
||||
}
|
5
core/vendor/mikey179/vfsStream/readme.md
vendored
Normal file
5
core/vendor/mikey179/vfsStream/readme.md
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
For more information have a look in the [wiki](https://github.com/mikey179/vfsStream/wiki).
|
||||
|
||||
[](http://travis-ci.org/mikey179/vfsStream) [](https://coveralls.io/r/mikey179/vfsStream?branch=master)
|
||||
|
||||
[](https://packagist.org/packages/mikey179/vfsStream) [](//packagist.org/packages/mikey179/vfsStream)
|
36
core/vendor/mikey179/vfsStream/src/main/php/org/bovigo/vfs/DotDirectory.php
vendored
Normal file
36
core/vendor/mikey179/vfsStream/src/main/php/org/bovigo/vfs/DotDirectory.php
vendored
Normal file
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of vfsStream.
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @package org\bovigo\vfs
|
||||
*/
|
||||
namespace org\bovigo\vfs;
|
||||
/**
|
||||
* Directory container.
|
||||
*/
|
||||
class DotDirectory extends vfsStreamDirectory
|
||||
{
|
||||
/**
|
||||
* returns iterator for the children
|
||||
*
|
||||
* @return vfsStreamContainerIterator
|
||||
*/
|
||||
public function getIterator()
|
||||
{
|
||||
return new \ArrayIterator(array());
|
||||
}
|
||||
|
||||
/**
|
||||
* checks whether dir is a dot dir
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isDot()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
?>
|
87
core/vendor/mikey179/vfsStream/src/main/php/org/bovigo/vfs/Quota.php
vendored
Normal file
87
core/vendor/mikey179/vfsStream/src/main/php/org/bovigo/vfs/Quota.php
vendored
Normal file
|
@ -0,0 +1,87 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of vfsStream.
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @package org\bovigo\vfs
|
||||
*/
|
||||
namespace org\bovigo\vfs;
|
||||
/**
|
||||
* Represents a quota for disk space.
|
||||
*
|
||||
* @since 1.1.0
|
||||
* @internal
|
||||
*/
|
||||
class Quota
|
||||
{
|
||||
/**
|
||||
* unlimited quota
|
||||
*/
|
||||
const UNLIMITED = -1;
|
||||
/**
|
||||
* quota in bytes
|
||||
*
|
||||
* A value of -1 is treated as unlimited.
|
||||
*
|
||||
* @type int
|
||||
*/
|
||||
private $amount;
|
||||
|
||||
/**
|
||||
* constructor
|
||||
*
|
||||
* @param int $amount quota in bytes
|
||||
*/
|
||||
public function __construct($amount)
|
||||
{
|
||||
$this->amount = $amount;
|
||||
}
|
||||
|
||||
/**
|
||||
* create with unlimited space
|
||||
*
|
||||
* @return Quota
|
||||
*/
|
||||
public static function unlimited()
|
||||
{
|
||||
return new self(self::UNLIMITED);
|
||||
}
|
||||
|
||||
/**
|
||||
* checks if a quota is set
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isLimited()
|
||||
{
|
||||
return self::UNLIMITED < $this->amount;
|
||||
}
|
||||
|
||||
/**
|
||||
* checks if given used space exceeda quota limit
|
||||
*
|
||||
*
|
||||
* @param int $usedSpace
|
||||
* @return int
|
||||
*/
|
||||
public function spaceLeft($usedSpace)
|
||||
{
|
||||
if (self::UNLIMITED === $this->amount) {
|
||||
return $usedSpace;
|
||||
}
|
||||
|
||||
if ($usedSpace >= $this->amount) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
$spaceLeft = $this->amount - $usedSpace;
|
||||
if (0 >= $spaceLeft) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return $spaceLeft;
|
||||
}
|
||||
}
|
||||
?>
|
71
core/vendor/mikey179/vfsStream/src/main/php/org/bovigo/vfs/content/FileContent.php
vendored
Normal file
71
core/vendor/mikey179/vfsStream/src/main/php/org/bovigo/vfs/content/FileContent.php
vendored
Normal file
|
@ -0,0 +1,71 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of vfsStream.
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @package org\bovigo\vfs
|
||||
*/
|
||||
namespace org\bovigo\vfs\content;
|
||||
/**
|
||||
* Interface for actual file contents.
|
||||
*
|
||||
* @since 1.3.0
|
||||
*/
|
||||
interface FileContent
|
||||
{
|
||||
/**
|
||||
* returns actual content
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function content();
|
||||
|
||||
/**
|
||||
* returns size of content
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function size();
|
||||
|
||||
/**
|
||||
* reads the given amount of bytes from content
|
||||
*
|
||||
* @param int $count
|
||||
* @return string
|
||||
*/
|
||||
public function read($count);
|
||||
|
||||
/**
|
||||
* seeks to the given offset
|
||||
*
|
||||
* @param int $offset
|
||||
* @param int $whence
|
||||
* @return bool
|
||||
*/
|
||||
public function seek($offset, $whence);
|
||||
|
||||
/**
|
||||
* checks whether pointer is at end of file
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function eof();
|
||||
|
||||
/**
|
||||
* writes an amount of data
|
||||
*
|
||||
* @param string $data
|
||||
* @return amount of written bytes
|
||||
*/
|
||||
public function write($data);
|
||||
|
||||
/**
|
||||
* Truncates a file to a given length
|
||||
*
|
||||
* @param int $size length to truncate file to
|
||||
* @return bool
|
||||
*/
|
||||
public function truncate($size);
|
||||
}
|
167
core/vendor/mikey179/vfsStream/src/main/php/org/bovigo/vfs/content/LargeFileContent.php
vendored
Normal file
167
core/vendor/mikey179/vfsStream/src/main/php/org/bovigo/vfs/content/LargeFileContent.php
vendored
Normal file
|
@ -0,0 +1,167 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of vfsStream.
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @package org\bovigo\vfs
|
||||
*/
|
||||
namespace org\bovigo\vfs\content;
|
||||
/**
|
||||
* File content implementation to mock large files.
|
||||
*
|
||||
* When content is written via write() the data will be written into the
|
||||
* positions according to the current offset.
|
||||
* When content is read via read() it will use the already written data. If no
|
||||
* data is written at the offsets to read those offsets will be filled with
|
||||
* spaces.
|
||||
* Please note that accessing the whole content via content() will deliver a
|
||||
* string with the length of the originally defined size. It is not advisable to
|
||||
* do so with large sizes, except you have enough memory and time. :-)
|
||||
*
|
||||
* @since 1.3.0
|
||||
*/
|
||||
class LargeFileContent extends SeekableFileContent implements FileContent
|
||||
{
|
||||
/**
|
||||
* byte array of written content
|
||||
*
|
||||
* @type char[]
|
||||
*/
|
||||
private $content = array();
|
||||
/**
|
||||
* file size in bytes
|
||||
*
|
||||
* @type int
|
||||
*/
|
||||
private $size;
|
||||
|
||||
/**
|
||||
* constructor
|
||||
*
|
||||
* @param int $size file size in bytes
|
||||
*/
|
||||
public function __construct($size)
|
||||
{
|
||||
$this->size = $size;
|
||||
}
|
||||
|
||||
/**
|
||||
* create large file with given size in kilobyte
|
||||
*
|
||||
* @param int $kilobyte
|
||||
* @return LargeFileContent
|
||||
*/
|
||||
public static function withKilobytes($kilobyte)
|
||||
{
|
||||
return new self($kilobyte * 1024);
|
||||
}
|
||||
|
||||
/**
|
||||
* create large file with given size in megabyte
|
||||
*
|
||||
* @param int $megabyte
|
||||
* @return LargeFileContent
|
||||
*/
|
||||
public static function withMegabytes($megabyte)
|
||||
{
|
||||
return self::withKilobytes($megabyte * 1024);
|
||||
}
|
||||
|
||||
/**
|
||||
* create large file with given size in gigabyte
|
||||
*
|
||||
* @param int $gigabyte
|
||||
* @return LargeFileContent
|
||||
*/
|
||||
public static function withGigabytes($gigabyte)
|
||||
{
|
||||
return self::withMegabytes($gigabyte * 1024);
|
||||
}
|
||||
|
||||
/**
|
||||
* returns actual content
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function content()
|
||||
{
|
||||
return $this->doRead(0, $this->size);
|
||||
}
|
||||
|
||||
/**
|
||||
* returns size of content
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function size()
|
||||
{
|
||||
return $this->size;
|
||||
}
|
||||
|
||||
/**
|
||||
* actual reading of given byte count starting at given offset
|
||||
*
|
||||
* @param int $offset
|
||||
* @param int $count
|
||||
*/
|
||||
protected function doRead($offset, $count)
|
||||
{
|
||||
if (($offset + $count) > $this->size) {
|
||||
$count = $this->size - $offset;
|
||||
}
|
||||
|
||||
$result = '';
|
||||
for ($i = 0; $i < $count; $i++) {
|
||||
if (isset($this->content[$i + $offset])) {
|
||||
$result .= $this->content[$i + $offset];
|
||||
} else {
|
||||
$result .= ' ';
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* actual writing of data with specified length at given offset
|
||||
*
|
||||
* @param string $data
|
||||
* @param int $offset
|
||||
* @param int $length
|
||||
*/
|
||||
protected function doWrite($data, $offset, $length)
|
||||
{
|
||||
for ($i = 0; $i < $length; $i++) {
|
||||
$this->content[$i + $offset] = $data{$i};
|
||||
}
|
||||
|
||||
if ($offset >= $this->size) {
|
||||
$this->size += $length;
|
||||
} elseif (($offset + $length) > $this->size) {
|
||||
$this->size = $offset + $length;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Truncates a file to a given length
|
||||
*
|
||||
* @param int $size length to truncate file to
|
||||
* @return bool
|
||||
*/
|
||||
public function truncate($size)
|
||||
{
|
||||
$this->size = $size;
|
||||
foreach (array_filter(array_keys($this->content),
|
||||
function($pos) use ($size)
|
||||
{
|
||||
return $pos >= $size;
|
||||
}
|
||||
) as $removePos) {
|
||||
unset($this->content[$removePos]);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
129
core/vendor/mikey179/vfsStream/src/main/php/org/bovigo/vfs/content/SeekableFileContent.php
vendored
Normal file
129
core/vendor/mikey179/vfsStream/src/main/php/org/bovigo/vfs/content/SeekableFileContent.php
vendored
Normal file
|
@ -0,0 +1,129 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of vfsStream.
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @package org\bovigo\vfs
|
||||
*/
|
||||
namespace org\bovigo\vfs\content;
|
||||
/**
|
||||
* Default implementation for file contents based on simple strings.
|
||||
*
|
||||
* @since 1.3.0
|
||||
*/
|
||||
abstract class SeekableFileContent implements FileContent
|
||||
{
|
||||
/**
|
||||
* current position within content
|
||||
*
|
||||
* @type int
|
||||
*/
|
||||
private $offset = 0;
|
||||
|
||||
/**
|
||||
* reads the given amount of bytes from content
|
||||
*
|
||||
* @param int $count
|
||||
* @return string
|
||||
*/
|
||||
public function read($count)
|
||||
{
|
||||
$data = $this->doRead($this->offset, $count);
|
||||
$this->offset += $count;
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* actual reading of given byte count starting at given offset
|
||||
*
|
||||
* @param int $offset
|
||||
* @param int $count
|
||||
*/
|
||||
protected abstract function doRead($offset, $count);
|
||||
|
||||
/**
|
||||
* seeks to the given offset
|
||||
*
|
||||
* @param int $offset
|
||||
* @param int $whence
|
||||
* @return bool
|
||||
*/
|
||||
public function seek($offset, $whence)
|
||||
{
|
||||
switch ($whence) {
|
||||
case SEEK_CUR:
|
||||
$this->offset += $offset;
|
||||
return true;
|
||||
|
||||
case SEEK_END:
|
||||
$this->offset = $this->size() + $offset;
|
||||
return true;
|
||||
|
||||
case SEEK_SET:
|
||||
$this->offset = $offset;
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* checks whether pointer is at end of file
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function eof()
|
||||
{
|
||||
return $this->size() <= $this->offset;
|
||||
}
|
||||
|
||||
/**
|
||||
* writes an amount of data
|
||||
*
|
||||
* @param string $data
|
||||
* @return amount of written bytes
|
||||
*/
|
||||
public function write($data)
|
||||
{
|
||||
$dataLength = strlen($data);
|
||||
$this->doWrite($data, $this->offset, $dataLength);
|
||||
$this->offset += $dataLength;
|
||||
return $dataLength;
|
||||
}
|
||||
|
||||
/**
|
||||
* actual writing of data with specified length at given offset
|
||||
*
|
||||
* @param string $data
|
||||
* @param int $offset
|
||||
* @param int $length
|
||||
*/
|
||||
protected abstract function doWrite($data, $offset, $length);
|
||||
|
||||
/**
|
||||
* for backwards compatibility with vfsStreamFile::bytesRead()
|
||||
*
|
||||
* @return int
|
||||
* @deprecated
|
||||
*/
|
||||
public function bytesRead()
|
||||
{
|
||||
return $this->offset;
|
||||
}
|
||||
|
||||
/**
|
||||
* for backwards compatibility with vfsStreamFile::readUntilEnd()
|
||||
*
|
||||
* @return string
|
||||
* @deprecated
|
||||
*/
|
||||
public function readUntilEnd()
|
||||
{
|
||||
return substr($this->content(), $this->offset);
|
||||
}
|
||||
}
|
97
core/vendor/mikey179/vfsStream/src/main/php/org/bovigo/vfs/content/StringBasedFileContent.php
vendored
Normal file
97
core/vendor/mikey179/vfsStream/src/main/php/org/bovigo/vfs/content/StringBasedFileContent.php
vendored
Normal file
|
@ -0,0 +1,97 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of vfsStream.
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @package org\bovigo\vfs
|
||||
*/
|
||||
namespace org\bovigo\vfs\content;
|
||||
/**
|
||||
* Default implementation for file contents based on simple strings.
|
||||
*
|
||||
* @since 1.3.0
|
||||
*/
|
||||
class StringBasedFileContent extends SeekableFileContent implements FileContent
|
||||
{
|
||||
/**
|
||||
* actual content
|
||||
*
|
||||
* @type string
|
||||
*/
|
||||
private $content;
|
||||
|
||||
/**
|
||||
* constructor
|
||||
*
|
||||
* @param string $content
|
||||
*/
|
||||
public function __construct($content)
|
||||
{
|
||||
$this->content = $content;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns actual content
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function content()
|
||||
{
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns size of content
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function size()
|
||||
{
|
||||
return strlen($this->content);
|
||||
}
|
||||
|
||||
/**
|
||||
* actual reading of length starting at given offset
|
||||
*
|
||||
* @param int $offset
|
||||
* @param int $count
|
||||
*/
|
||||
protected function doRead($offset, $count)
|
||||
{
|
||||
return substr($this->content, $offset, $count);
|
||||
}
|
||||
|
||||
/**
|
||||
* actual writing of data with specified length at given offset
|
||||
*
|
||||
* @param string $data
|
||||
* @param int $offset
|
||||
* @param int $length
|
||||
*/
|
||||
protected function doWrite($data, $offset, $length)
|
||||
{
|
||||
$this->content = substr($this->content, 0, $offset)
|
||||
. $data
|
||||
. substr($this->content, $offset + $length);
|
||||
}
|
||||
|
||||
/**
|
||||
* Truncates a file to a given length
|
||||
*
|
||||
* @param int $size length to truncate file to
|
||||
* @return bool
|
||||
*/
|
||||
public function truncate($size)
|
||||
{
|
||||
if ($size > $this->size()) {
|
||||
// Pad with null-chars if we're "truncating up"
|
||||
$this->content .= str_repeat("\0", $size - $this->size());
|
||||
} else {
|
||||
$this->content = substr($this->content, 0, $size);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
462
core/vendor/mikey179/vfsStream/src/main/php/org/bovigo/vfs/vfsStream.php
vendored
Normal file
462
core/vendor/mikey179/vfsStream/src/main/php/org/bovigo/vfs/vfsStream.php
vendored
Normal file
|
@ -0,0 +1,462 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of vfsStream.
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @package org\bovigo\vfs
|
||||
*/
|
||||
namespace org\bovigo\vfs;
|
||||
use org\bovigo\vfs\content\LargeFileContent;
|
||||
use org\bovigo\vfs\visitor\vfsStreamVisitor;
|
||||
/**
|
||||
* Some utility methods for vfsStream.
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
class vfsStream
|
||||
{
|
||||
/**
|
||||
* url scheme
|
||||
*/
|
||||
const SCHEME = 'vfs';
|
||||
/**
|
||||
* owner: root
|
||||
*/
|
||||
const OWNER_ROOT = 0;
|
||||
/**
|
||||
* owner: user 1
|
||||
*/
|
||||
const OWNER_USER_1 = 1;
|
||||
/**
|
||||
* owner: user 2
|
||||
*/
|
||||
const OWNER_USER_2 = 2;
|
||||
/**
|
||||
* group: root
|
||||
*/
|
||||
const GROUP_ROOT = 0;
|
||||
/**
|
||||
* group: user 1
|
||||
*/
|
||||
const GROUP_USER_1 = 1;
|
||||
/**
|
||||
* group: user 2
|
||||
*/
|
||||
const GROUP_USER_2 = 2;
|
||||
/**
|
||||
* initial umask setting
|
||||
*
|
||||
* @type int
|
||||
*/
|
||||
protected static $umask = 0000;
|
||||
/**
|
||||
* switch whether dotfiles are enabled in directory listings
|
||||
*
|
||||
* @type bool
|
||||
*/
|
||||
private static $dotFiles = true;
|
||||
|
||||
/**
|
||||
* prepends the scheme to the given URL
|
||||
*
|
||||
* @param string $path path to translate to vfsStream url
|
||||
* @return string
|
||||
*/
|
||||
public static function url($path)
|
||||
{
|
||||
return self::SCHEME . '://' . str_replace('\\', '/', $path);
|
||||
}
|
||||
|
||||
/**
|
||||
* restores the path from the url
|
||||
*
|
||||
* @param string $url vfsStream url to translate into path
|
||||
* @return string
|
||||
*/
|
||||
public static function path($url)
|
||||
{
|
||||
// remove line feeds and trailing whitespaces and path separators
|
||||
$path = trim($url, " \t\r\n\0\x0B/\\");
|
||||
$path = substr($path, strlen(self::SCHEME . '://'));
|
||||
$path = str_replace('\\', '/', $path);
|
||||
// replace double slashes with single slashes
|
||||
$path = str_replace('//', '/', $path);
|
||||
return urldecode($path);
|
||||
}
|
||||
|
||||
/**
|
||||
* sets new umask setting and returns previous umask setting
|
||||
*
|
||||
* If no value is given only the current umask setting is returned.
|
||||
*
|
||||
* @param int $umask new umask setting
|
||||
* @return int
|
||||
* @since 0.8.0
|
||||
*/
|
||||
public static function umask($umask = null)
|
||||
{
|
||||
$oldUmask = self::$umask;
|
||||
if (null !== $umask) {
|
||||
self::$umask = $umask;
|
||||
}
|
||||
|
||||
return $oldUmask;
|
||||
}
|
||||
|
||||
/**
|
||||
* helper method for setting up vfsStream in unit tests
|
||||
*
|
||||
* Instead of
|
||||
* vfsStreamWrapper::register();
|
||||
* vfsStreamWrapper::setRoot(vfsStream::newDirectory('root'));
|
||||
* you can simply do
|
||||
* vfsStream::setup()
|
||||
* which yields the same result. Additionally, the method returns the
|
||||
* freshly created root directory which you can use to make further
|
||||
* adjustments to it.
|
||||
*
|
||||
* Assumed $structure contains an array like this:
|
||||
* <code>
|
||||
* array('Core' = array('AbstractFactory' => array('test.php' => 'some text content',
|
||||
* 'other.php' => 'Some more text content',
|
||||
* 'Invalid.csv' => 'Something else',
|
||||
* ),
|
||||
* 'AnEmptyFolder' => array(),
|
||||
* 'badlocation.php' => 'some bad content',
|
||||
* )
|
||||
* )
|
||||
* </code>
|
||||
* the resulting directory tree will look like this:
|
||||
* <pre>
|
||||
* root
|
||||
* \- Core
|
||||
* |- badlocation.php
|
||||
* |- AbstractFactory
|
||||
* | |- test.php
|
||||
* | |- other.php
|
||||
* | \- Invalid.csv
|
||||
* \- AnEmptyFolder
|
||||
* </pre>
|
||||
* Arrays will become directories with their key as directory name, and
|
||||
* strings becomes files with their key as file name and their value as file
|
||||
* content.
|
||||
*
|
||||
* @param string $rootDirName name of root directory
|
||||
* @param int $permissions file permissions of root directory
|
||||
* @param array $structure directory structure to add under root directory
|
||||
* @return \org\bovigo\vfs\vfsStreamDirectory
|
||||
* @since 0.7.0
|
||||
* @see https://github.com/mikey179/vfsStream/issues/14
|
||||
* @see https://github.com/mikey179/vfsStream/issues/20
|
||||
*/
|
||||
public static function setup($rootDirName = 'root', $permissions = null, array $structure = array())
|
||||
{
|
||||
vfsStreamWrapper::register();
|
||||
return self::create($structure, vfsStreamWrapper::setRoot(self::newDirectory($rootDirName, $permissions)));
|
||||
}
|
||||
|
||||
/**
|
||||
* creates vfsStream directory structure from an array and adds it to given base dir
|
||||
*
|
||||
* Assumed $structure contains an array like this:
|
||||
* <code>
|
||||
* array('Core' = array('AbstractFactory' => array('test.php' => 'some text content',
|
||||
* 'other.php' => 'Some more text content',
|
||||
* 'Invalid.csv' => 'Something else',
|
||||
* ),
|
||||
* 'AnEmptyFolder' => array(),
|
||||
* 'badlocation.php' => 'some bad content',
|
||||
* )
|
||||
* )
|
||||
* </code>
|
||||
* the resulting directory tree will look like this:
|
||||
* <pre>
|
||||
* baseDir
|
||||
* \- Core
|
||||
* |- badlocation.php
|
||||
* |- AbstractFactory
|
||||
* | |- test.php
|
||||
* | |- other.php
|
||||
* | \- Invalid.csv
|
||||
* \- AnEmptyFolder
|
||||
* </pre>
|
||||
* Arrays will become directories with their key as directory name, and
|
||||
* strings becomes files with their key as file name and their value as file
|
||||
* content.
|
||||
*
|
||||
* If no baseDir is given it will try to add the structure to the existing
|
||||
* root directory without replacing existing childs except those with equal
|
||||
* names.
|
||||
*
|
||||
* @param array $structure directory structure to add under root directory
|
||||
* @param vfsStreamDirectory $baseDir base directory to add structure to
|
||||
* @return vfsStreamDirectory
|
||||
* @throws \InvalidArgumentException
|
||||
* @since 0.10.0
|
||||
* @see https://github.com/mikey179/vfsStream/issues/14
|
||||
* @see https://github.com/mikey179/vfsStream/issues/20
|
||||
*/
|
||||
public static function create(array $structure, vfsStreamDirectory $baseDir = null)
|
||||
{
|
||||
if (null === $baseDir) {
|
||||
$baseDir = vfsStreamWrapper::getRoot();
|
||||
}
|
||||
|
||||
if (null === $baseDir) {
|
||||
throw new \InvalidArgumentException('No baseDir given and no root directory set.');
|
||||
}
|
||||
|
||||
return self::addStructure($structure, $baseDir);
|
||||
}
|
||||
|
||||
/**
|
||||
* helper method to create subdirectories recursively
|
||||
*
|
||||
* @param array $structure subdirectory structure to add
|
||||
* @param vfsStreamDirectory $baseDir directory to add the structure to
|
||||
* @return vfsStreamDirectory
|
||||
*/
|
||||
protected static function addStructure(array $structure, vfsStreamDirectory $baseDir)
|
||||
{
|
||||
foreach ($structure as $name => $data) {
|
||||
$name = (string) $name;
|
||||
if (is_array($data) === true) {
|
||||
self::addStructure($data, self::newDirectory($name)->at($baseDir));
|
||||
} elseif (is_string($data) === true) {
|
||||
$matches = null;
|
||||
preg_match('/^\[(.*)\]$/', $name, $matches);
|
||||
if ($matches !== array()) {
|
||||
self::newBlock($matches[1])->withContent($data)->at($baseDir);
|
||||
} else {
|
||||
self::newFile($name)->withContent($data)->at($baseDir);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $baseDir;
|
||||
}
|
||||
|
||||
/**
|
||||
* copies the file system structure from given path into the base dir
|
||||
*
|
||||
* If no baseDir is given it will try to add the structure to the existing
|
||||
* root directory without replacing existing childs except those with equal
|
||||
* names.
|
||||
* File permissions are copied as well.
|
||||
* Please note that file contents will only be copied if their file size
|
||||
* does not exceed the given $maxFileSize which defaults to 1024 KB. In case
|
||||
* the file is larger file content will be mocked, see
|
||||
* https://github.com/mikey179/vfsStream/wiki/MockingLargeFiles.
|
||||
*
|
||||
* @param string $path path to copy the structure from
|
||||
* @param vfsStreamDirectory $baseDir directory to add the structure to
|
||||
* @param int $maxFileSize maximum file size of files to copy content from
|
||||
* @return vfsStreamDirectory
|
||||
* @throws \InvalidArgumentException
|
||||
* @since 0.11.0
|
||||
* @see https://github.com/mikey179/vfsStream/issues/4
|
||||
*/
|
||||
public static function copyFromFileSystem($path, vfsStreamDirectory $baseDir = null, $maxFileSize = 1048576)
|
||||
{
|
||||
if (null === $baseDir) {
|
||||
$baseDir = vfsStreamWrapper::getRoot();
|
||||
}
|
||||
|
||||
if (null === $baseDir) {
|
||||
throw new \InvalidArgumentException('No baseDir given and no root directory set.');
|
||||
}
|
||||
|
||||
$dir = new \DirectoryIterator($path);
|
||||
foreach ($dir as $fileinfo) {
|
||||
switch (filetype($fileinfo->getPathname())) {
|
||||
case 'file':
|
||||
if ($fileinfo->getSize() <= $maxFileSize) {
|
||||
$content = file_get_contents($fileinfo->getPathname());
|
||||
} else {
|
||||
$content = new LargeFileContent($fileinfo->getSize());
|
||||
}
|
||||
|
||||
self::newFile(
|
||||
$fileinfo->getFilename(),
|
||||
octdec(substr(sprintf('%o', $fileinfo->getPerms()), -4))
|
||||
)
|
||||
->withContent($content)
|
||||
->at($baseDir);
|
||||
break;
|
||||
|
||||
case 'dir':
|
||||
if (!$fileinfo->isDot()) {
|
||||
self::copyFromFileSystem(
|
||||
$fileinfo->getPathname(),
|
||||
self::newDirectory(
|
||||
$fileinfo->getFilename(),
|
||||
octdec(substr(sprintf('%o', $fileinfo->getPerms()), -4))
|
||||
)->at($baseDir),
|
||||
$maxFileSize
|
||||
);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'block':
|
||||
self::newBlock(
|
||||
$fileinfo->getFilename(),
|
||||
octdec(substr(sprintf('%o', $fileinfo->getPerms()), -4))
|
||||
)->at($baseDir);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $baseDir;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns a new file with given name
|
||||
*
|
||||
* @param string $name name of file to create
|
||||
* @param int $permissions permissions of file to create
|
||||
* @return vfsStreamFile
|
||||
*/
|
||||
public static function newFile($name, $permissions = null)
|
||||
{
|
||||
return new vfsStreamFile($name, $permissions);
|
||||
}
|
||||
|
||||
/**
|
||||
* returns a new directory with given name
|
||||
*
|
||||
* If the name contains slashes, a new directory structure will be created.
|
||||
* The returned directory will always be the parent directory of this
|
||||
* directory structure.
|
||||
*
|
||||
* @param string $name name of directory to create
|
||||
* @param int $permissions permissions of directory to create
|
||||
* @return vfsStreamDirectory
|
||||
*/
|
||||
public static function newDirectory($name, $permissions = null)
|
||||
{
|
||||
if ('/' === $name{0}) {
|
||||
$name = substr($name, 1);
|
||||
}
|
||||
|
||||
$firstSlash = strpos($name, '/');
|
||||
if (false === $firstSlash) {
|
||||
return new vfsStreamDirectory($name, $permissions);
|
||||
}
|
||||
|
||||
$ownName = substr($name, 0, $firstSlash);
|
||||
$subDirs = substr($name, $firstSlash + 1);
|
||||
$directory = new vfsStreamDirectory($ownName, $permissions);
|
||||
self::newDirectory($subDirs, $permissions)->at($directory);
|
||||
return $directory;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns a new block with the given name
|
||||
*
|
||||
* @param string $name name of the block device
|
||||
* @param int $permissions permissions of block to create
|
||||
* @return vfsStreamBlock
|
||||
*/
|
||||
public static function newBlock($name, $permissions = null)
|
||||
{
|
||||
return new vfsStreamBlock($name, $permissions);
|
||||
}
|
||||
|
||||
/**
|
||||
* returns current user
|
||||
*
|
||||
* If the system does not support posix_getuid() the current user will be root (0).
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public static function getCurrentUser()
|
||||
{
|
||||
return function_exists('posix_getuid') ? posix_getuid() : self::OWNER_ROOT;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns current group
|
||||
*
|
||||
* If the system does not support posix_getgid() the current group will be root (0).
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public static function getCurrentGroup()
|
||||
{
|
||||
return function_exists('posix_getgid') ? posix_getgid() : self::GROUP_ROOT;
|
||||
}
|
||||
|
||||
/**
|
||||
* use visitor to inspect a content structure
|
||||
*
|
||||
* If the given content is null it will fall back to use the current root
|
||||
* directory of the stream wrapper.
|
||||
*
|
||||
* Returns given visitor for method chaining comfort.
|
||||
*
|
||||
* @param vfsStreamVisitor $visitor the visitor who inspects
|
||||
* @param vfsStreamContent $content directory structure to inspect
|
||||
* @return vfsStreamVisitor
|
||||
* @throws \InvalidArgumentException
|
||||
* @since 0.10.0
|
||||
* @see https://github.com/mikey179/vfsStream/issues/10
|
||||
*/
|
||||
public static function inspect(vfsStreamVisitor $visitor, vfsStreamContent $content = null)
|
||||
{
|
||||
if (null !== $content) {
|
||||
return $visitor->visit($content);
|
||||
}
|
||||
|
||||
$root = vfsStreamWrapper::getRoot();
|
||||
if (null === $root) {
|
||||
throw new \InvalidArgumentException('No content given and no root directory set.');
|
||||
}
|
||||
|
||||
return $visitor->visitDirectory($root);
|
||||
}
|
||||
|
||||
/**
|
||||
* sets quota to given amount of bytes
|
||||
*
|
||||
* @param int $bytes
|
||||
* @since 1.1.0
|
||||
*/
|
||||
public static function setQuota($bytes)
|
||||
{
|
||||
vfsStreamWrapper::setQuota(new Quota($bytes));
|
||||
}
|
||||
|
||||
/**
|
||||
* checks if vfsStream lists dotfiles in directory listings
|
||||
*
|
||||
* @return bool
|
||||
* @since 1.3.0
|
||||
*/
|
||||
public static function useDotfiles()
|
||||
{
|
||||
return self::$dotFiles;
|
||||
}
|
||||
|
||||
/**
|
||||
* disable dotfiles in directory listings
|
||||
*
|
||||
* @since 1.3.0
|
||||
*/
|
||||
public static function disableDotfiles()
|
||||
{
|
||||
self::$dotFiles = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* enable dotfiles in directory listings
|
||||
*
|
||||
* @since 1.3.0
|
||||
*/
|
||||
public static function enableDotfiles()
|
||||
{
|
||||
self::$dotFiles = true;
|
||||
}
|
||||
}
|
419
core/vendor/mikey179/vfsStream/src/main/php/org/bovigo/vfs/vfsStreamAbstractContent.php
vendored
Normal file
419
core/vendor/mikey179/vfsStream/src/main/php/org/bovigo/vfs/vfsStreamAbstractContent.php
vendored
Normal file
|
@ -0,0 +1,419 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of vfsStream.
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @package org\bovigo\vfs
|
||||
*/
|
||||
namespace org\bovigo\vfs;
|
||||
/**
|
||||
* Base stream contents container.
|
||||
*/
|
||||
abstract class vfsStreamAbstractContent implements vfsStreamContent
|
||||
{
|
||||
/**
|
||||
* name of the container
|
||||
*
|
||||
* @type string
|
||||
*/
|
||||
protected $name;
|
||||
/**
|
||||
* type of the container
|
||||
*
|
||||
* @type string
|
||||
*/
|
||||
protected $type;
|
||||
/**
|
||||
* timestamp of last access
|
||||
*
|
||||
* @type int
|
||||
*/
|
||||
protected $lastAccessed;
|
||||
/**
|
||||
* timestamp of last attribute modification
|
||||
*
|
||||
* @type int
|
||||
*/
|
||||
protected $lastAttributeModified;
|
||||
/**
|
||||
* timestamp of last modification
|
||||
*
|
||||
* @type int
|
||||
*/
|
||||
protected $lastModified;
|
||||
/**
|
||||
* permissions for content
|
||||
*
|
||||
* @type int
|
||||
*/
|
||||
protected $permissions;
|
||||
/**
|
||||
* owner of the file
|
||||
*
|
||||
* @type int
|
||||
*/
|
||||
protected $user;
|
||||
/**
|
||||
* owner group of the file
|
||||
*
|
||||
* @type int
|
||||
*/
|
||||
protected $group;
|
||||
/**
|
||||
* path to to this content
|
||||
*
|
||||
* @type string
|
||||
*/
|
||||
private $parentPath;
|
||||
|
||||
/**
|
||||
* constructor
|
||||
*
|
||||
* @param string $name
|
||||
* @param int $permissions optional
|
||||
*/
|
||||
public function __construct($name, $permissions = null)
|
||||
{
|
||||
$this->name = $name;
|
||||
$time = time();
|
||||
if (null === $permissions) {
|
||||
$permissions = $this->getDefaultPermissions() & ~vfsStream::umask();
|
||||
}
|
||||
|
||||
$this->lastAccessed = $time;
|
||||
$this->lastAttributeModified = $time;
|
||||
$this->lastModified = $time;
|
||||
$this->permissions = $permissions;
|
||||
$this->user = vfsStream::getCurrentUser();
|
||||
$this->group = vfsStream::getCurrentGroup();
|
||||
}
|
||||
|
||||
/**
|
||||
* returns default permissions for concrete implementation
|
||||
*
|
||||
* @return int
|
||||
* @since 0.8.0
|
||||
*/
|
||||
protected abstract function getDefaultPermissions();
|
||||
|
||||
/**
|
||||
* returns the file name of the content
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* renames the content
|
||||
*
|
||||
* @param string $newName
|
||||
*/
|
||||
public function rename($newName)
|
||||
{
|
||||
$this->name = $newName;
|
||||
}
|
||||
|
||||
/**
|
||||
* checks whether the container can be applied to given name
|
||||
*
|
||||
* @param string $name
|
||||
* @return bool
|
||||
*/
|
||||
public function appliesTo($name)
|
||||
{
|
||||
if ($name === $this->name) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$segment_name = $this->name.'/';
|
||||
return (strncmp($segment_name, $name, strlen($segment_name)) == 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the type of the container
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getType()
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* sets the last modification time of the stream content
|
||||
*
|
||||
* @param int $filemtime
|
||||
* @return vfsStreamContent
|
||||
*/
|
||||
public function lastModified($filemtime)
|
||||
{
|
||||
$this->lastModified = $filemtime;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the last modification time of the stream content
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function filemtime()
|
||||
{
|
||||
return $this->lastModified;
|
||||
}
|
||||
|
||||
/**
|
||||
* sets last access time of the stream content
|
||||
*
|
||||
* @param int $fileatime
|
||||
* @return vfsStreamContent
|
||||
* @since 0.9
|
||||
*/
|
||||
public function lastAccessed($fileatime)
|
||||
{
|
||||
$this->lastAccessed = $fileatime;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the last access time of the stream content
|
||||
*
|
||||
* @return int
|
||||
* @since 0.9
|
||||
*/
|
||||
public function fileatime()
|
||||
{
|
||||
return $this->lastAccessed;
|
||||
}
|
||||
|
||||
/**
|
||||
* sets the last attribute modification time of the stream content
|
||||
*
|
||||
* @param int $filectime
|
||||
* @return vfsStreamContent
|
||||
* @since 0.9
|
||||
*/
|
||||
public function lastAttributeModified($filectime)
|
||||
{
|
||||
$this->lastAttributeModified = $filectime;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the last attribute modification time of the stream content
|
||||
*
|
||||
* @return int
|
||||
* @since 0.9
|
||||
*/
|
||||
public function filectime()
|
||||
{
|
||||
return $this->lastAttributeModified;
|
||||
}
|
||||
|
||||
/**
|
||||
* adds content to given container
|
||||
*
|
||||
* @param vfsStreamContainer $container
|
||||
* @return vfsStreamContent
|
||||
*/
|
||||
public function at(vfsStreamContainer $container)
|
||||
{
|
||||
$container->addChild($this);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* change file mode to given permissions
|
||||
*
|
||||
* @param int $permissions
|
||||
* @return vfsStreamContent
|
||||
*/
|
||||
public function chmod($permissions)
|
||||
{
|
||||
$this->permissions = $permissions;
|
||||
$this->lastAttributeModified = time();
|
||||
clearstatcache();
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns permissions
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getPermissions()
|
||||
{
|
||||
return $this->permissions;
|
||||
}
|
||||
|
||||
/**
|
||||
* checks whether content is readable
|
||||
*
|
||||
* @param int $user id of user to check for
|
||||
* @param int $group id of group to check for
|
||||
* @return bool
|
||||
*/
|
||||
public function isReadable($user, $group)
|
||||
{
|
||||
if ($this->user === $user) {
|
||||
$check = 0400;
|
||||
} elseif ($this->group === $group) {
|
||||
$check = 0040;
|
||||
} else {
|
||||
$check = 0004;
|
||||
}
|
||||
|
||||
return (bool) ($this->permissions & $check);
|
||||
}
|
||||
|
||||
/**
|
||||
* checks whether content is writable
|
||||
*
|
||||
* @param int $user id of user to check for
|
||||
* @param int $group id of group to check for
|
||||
* @return bool
|
||||
*/
|
||||
public function isWritable($user, $group)
|
||||
{
|
||||
if ($this->user === $user) {
|
||||
$check = 0200;
|
||||
} elseif ($this->group === $group) {
|
||||
$check = 0020;
|
||||
} else {
|
||||
$check = 0002;
|
||||
}
|
||||
|
||||
return (bool) ($this->permissions & $check);
|
||||
}
|
||||
|
||||
/**
|
||||
* checks whether content is executable
|
||||
*
|
||||
* @param int $user id of user to check for
|
||||
* @param int $group id of group to check for
|
||||
* @return bool
|
||||
*/
|
||||
public function isExecutable($user, $group)
|
||||
{
|
||||
if ($this->user === $user) {
|
||||
$check = 0100;
|
||||
} elseif ($this->group === $group) {
|
||||
$check = 0010;
|
||||
} else {
|
||||
$check = 0001;
|
||||
}
|
||||
|
||||
return (bool) ($this->permissions & $check);
|
||||
}
|
||||
|
||||
/**
|
||||
* change owner of file to given user
|
||||
*
|
||||
* @param int $user
|
||||
* @return vfsStreamContent
|
||||
*/
|
||||
public function chown($user)
|
||||
{
|
||||
$this->user = $user;
|
||||
$this->lastAttributeModified = time();
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* checks whether file is owned by given user
|
||||
*
|
||||
* @param int $user
|
||||
* @return bool
|
||||
*/
|
||||
public function isOwnedByUser($user)
|
||||
{
|
||||
return $this->user === $user;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns owner of file
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getUser()
|
||||
{
|
||||
return $this->user;
|
||||
}
|
||||
|
||||
/**
|
||||
* change owner group of file to given group
|
||||
*
|
||||
* @param int $group
|
||||
* @return vfsStreamContent
|
||||
*/
|
||||
public function chgrp($group)
|
||||
{
|
||||
$this->group = $group;
|
||||
$this->lastAttributeModified = time();
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* checks whether file is owned by group
|
||||
*
|
||||
* @param int $group
|
||||
* @return bool
|
||||
*/
|
||||
public function isOwnedByGroup($group)
|
||||
{
|
||||
return $this->group === $group;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns owner group of file
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getGroup()
|
||||
{
|
||||
return $this->group;
|
||||
}
|
||||
|
||||
/**
|
||||
* sets parent path
|
||||
*
|
||||
* @param string $parentPath
|
||||
* @internal only to be set by parent
|
||||
* @since 1.2.0
|
||||
*/
|
||||
public function setParentPath($parentPath)
|
||||
{
|
||||
$this->parentPath = $parentPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns path to this content
|
||||
*
|
||||
* @return string
|
||||
* @since 1.2.0
|
||||
*/
|
||||
public function path()
|
||||
{
|
||||
if (null === $this->parentPath) {
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
return $this->parentPath . '/' . $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns complete vfsStream url for this content
|
||||
*
|
||||
* @return string
|
||||
* @since 1.2.0
|
||||
*/
|
||||
public function url()
|
||||
{
|
||||
return vfsStream::url($this->path());
|
||||
}
|
||||
}
|
||||
?>
|
34
core/vendor/mikey179/vfsStream/src/main/php/org/bovigo/vfs/vfsStreamBlock.php
vendored
Normal file
34
core/vendor/mikey179/vfsStream/src/main/php/org/bovigo/vfs/vfsStreamBlock.php
vendored
Normal file
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of vfsStream.
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @package org\bovigo\vfs
|
||||
*/
|
||||
namespace org\bovigo\vfs;
|
||||
|
||||
/**
|
||||
* Block container.
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
class vfsStreamBlock extends vfsStreamFile
|
||||
{
|
||||
/**
|
||||
* constructor
|
||||
*
|
||||
* @param string $name
|
||||
* @param int $permissions optional
|
||||
*/
|
||||
public function __construct($name, $permissions = null)
|
||||
{
|
||||
if (empty($name)) {
|
||||
throw new vfsStreamException('Name of Block device was empty');
|
||||
}
|
||||
parent::__construct($name, $permissions);
|
||||
|
||||
$this->type = vfsStreamContent::TYPE_BLOCK;
|
||||
}
|
||||
}
|
62
core/vendor/mikey179/vfsStream/src/main/php/org/bovigo/vfs/vfsStreamContainer.php
vendored
Normal file
62
core/vendor/mikey179/vfsStream/src/main/php/org/bovigo/vfs/vfsStreamContainer.php
vendored
Normal file
|
@ -0,0 +1,62 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of vfsStream.
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @package org\bovigo\vfs
|
||||
*/
|
||||
namespace org\bovigo\vfs;
|
||||
/**
|
||||
* Interface for stream contents that are able to store other stream contents.
|
||||
*/
|
||||
interface vfsStreamContainer extends \IteratorAggregate
|
||||
{
|
||||
/**
|
||||
* adds child to the directory
|
||||
*
|
||||
* @param vfsStreamContent $child
|
||||
*/
|
||||
public function addChild(vfsStreamContent $child);
|
||||
|
||||
/**
|
||||
* removes child from the directory
|
||||
*
|
||||
* @param string $name
|
||||
* @return bool
|
||||
*/
|
||||
public function removeChild($name);
|
||||
|
||||
/**
|
||||
* checks whether the container contains a child with the given name
|
||||
*
|
||||
* @param string $name
|
||||
* @return bool
|
||||
*/
|
||||
public function hasChild($name);
|
||||
|
||||
/**
|
||||
* returns the child with the given name
|
||||
*
|
||||
* @param string $name
|
||||
* @return vfsStreamContent
|
||||
*/
|
||||
public function getChild($name);
|
||||
|
||||
/**
|
||||
* checks whether directory contains any children
|
||||
*
|
||||
* @return bool
|
||||
* @since 0.10.0
|
||||
*/
|
||||
public function hasChildren();
|
||||
|
||||
/**
|
||||
* returns a list of children for this directory
|
||||
*
|
||||
* @return vfsStreamContent[]
|
||||
*/
|
||||
public function getChildren();
|
||||
}
|
||||
?>
|
94
core/vendor/mikey179/vfsStream/src/main/php/org/bovigo/vfs/vfsStreamContainerIterator.php
vendored
Normal file
94
core/vendor/mikey179/vfsStream/src/main/php/org/bovigo/vfs/vfsStreamContainerIterator.php
vendored
Normal file
|
@ -0,0 +1,94 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of vfsStream.
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @package org\bovigo\vfs
|
||||
*/
|
||||
namespace org\bovigo\vfs;
|
||||
/**
|
||||
* Iterator for children of a directory container.
|
||||
*/
|
||||
class vfsStreamContainerIterator implements \Iterator
|
||||
{
|
||||
/**
|
||||
* list of children from container to iterate over
|
||||
*
|
||||
* @type vfsStreamContent[]
|
||||
*/
|
||||
protected $children;
|
||||
|
||||
/**
|
||||
* constructor
|
||||
*
|
||||
* @param vfsStreamContent[] $children
|
||||
*/
|
||||
public function __construct(array $children)
|
||||
{
|
||||
$this->children = $children;
|
||||
if (vfsStream::useDotfiles()) {
|
||||
array_unshift($this->children, new DotDirectory('.'), new DotDirectory('..'));
|
||||
}
|
||||
|
||||
reset($this->children);
|
||||
}
|
||||
|
||||
/**
|
||||
* resets children pointer
|
||||
*/
|
||||
public function rewind()
|
||||
{
|
||||
reset($this->children);
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the current child
|
||||
*
|
||||
* @return vfsStreamContent
|
||||
*/
|
||||
public function current()
|
||||
{
|
||||
$child = current($this->children);
|
||||
if (false === $child) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $child;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the name of the current child
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function key()
|
||||
{
|
||||
$child = current($this->children);
|
||||
if (false === $child) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $child->getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* iterates to next child
|
||||
*/
|
||||
public function next()
|
||||
{
|
||||
next($this->children);
|
||||
}
|
||||
|
||||
/**
|
||||
* checks if the current value is valid
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function valid()
|
||||
{
|
||||
return (false !== current($this->children));
|
||||
}
|
||||
}
|
||||
?>
|
214
core/vendor/mikey179/vfsStream/src/main/php/org/bovigo/vfs/vfsStreamContent.php
vendored
Normal file
214
core/vendor/mikey179/vfsStream/src/main/php/org/bovigo/vfs/vfsStreamContent.php
vendored
Normal file
|
@ -0,0 +1,214 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of vfsStream.
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @package org\bovigo\vfs
|
||||
*/
|
||||
namespace org\bovigo\vfs;
|
||||
/**
|
||||
* Interface for stream contents.
|
||||
*/
|
||||
interface vfsStreamContent
|
||||
{
|
||||
/**
|
||||
* stream content type: file
|
||||
*
|
||||
* @see getType()
|
||||
*/
|
||||
const TYPE_FILE = 0100000;
|
||||
/**
|
||||
* stream content type: directory
|
||||
*
|
||||
* @see getType()
|
||||
*/
|
||||
const TYPE_DIR = 0040000;
|
||||
/**
|
||||
* stream content type: symbolic link
|
||||
*
|
||||
* @see getType();
|
||||
*/
|
||||
#const TYPE_LINK = 0120000;
|
||||
|
||||
/**
|
||||
* stream content type: block
|
||||
*
|
||||
* @see getType()
|
||||
*/
|
||||
const TYPE_BLOCK = 0060000;
|
||||
|
||||
/**
|
||||
* returns the file name of the content
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName();
|
||||
|
||||
/**
|
||||
* renames the content
|
||||
*
|
||||
* @param string $newName
|
||||
*/
|
||||
public function rename($newName);
|
||||
|
||||
/**
|
||||
* checks whether the container can be applied to given name
|
||||
*
|
||||
* @param string $name
|
||||
* @return bool
|
||||
*/
|
||||
public function appliesTo($name);
|
||||
|
||||
/**
|
||||
* returns the type of the container
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getType();
|
||||
|
||||
/**
|
||||
* returns size of content
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function size();
|
||||
|
||||
/**
|
||||
* sets the last modification time of the stream content
|
||||
*
|
||||
* @param int $filemtime
|
||||
* @return vfsStreamContent
|
||||
*/
|
||||
public function lastModified($filemtime);
|
||||
|
||||
/**
|
||||
* returns the last modification time of the stream content
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function filemtime();
|
||||
|
||||
/**
|
||||
* adds content to given container
|
||||
*
|
||||
* @param vfsStreamContainer $container
|
||||
* @return vfsStreamContent
|
||||
*/
|
||||
public function at(vfsStreamContainer $container);
|
||||
|
||||
/**
|
||||
* change file mode to given permissions
|
||||
*
|
||||
* @param int $permissions
|
||||
* @return vfsStreamContent
|
||||
*/
|
||||
public function chmod($permissions);
|
||||
|
||||
/**
|
||||
* returns permissions
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getPermissions();
|
||||
|
||||
/**
|
||||
* checks whether content is readable
|
||||
*
|
||||
* @param int $user id of user to check for
|
||||
* @param int $group id of group to check for
|
||||
* @return bool
|
||||
*/
|
||||
public function isReadable($user, $group);
|
||||
|
||||
/**
|
||||
* checks whether content is writable
|
||||
*
|
||||
* @param int $user id of user to check for
|
||||
* @param int $group id of group to check for
|
||||
* @return bool
|
||||
*/
|
||||
public function isWritable($user, $group);
|
||||
|
||||
/**
|
||||
* checks whether content is executable
|
||||
*
|
||||
* @param int $user id of user to check for
|
||||
* @param int $group id of group to check for
|
||||
* @return bool
|
||||
*/
|
||||
public function isExecutable($user, $group);
|
||||
|
||||
/**
|
||||
* change owner of file to given user
|
||||
*
|
||||
* @param int $user
|
||||
* @return vfsStreamContent
|
||||
*/
|
||||
public function chown($user);
|
||||
|
||||
/**
|
||||
* checks whether file is owned by given user
|
||||
*
|
||||
* @param int $user
|
||||
* @return bool
|
||||
*/
|
||||
public function isOwnedByUser($user);
|
||||
|
||||
/**
|
||||
* returns owner of file
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getUser();
|
||||
|
||||
/**
|
||||
* change owner group of file to given group
|
||||
*
|
||||
* @param int $group
|
||||
* @return vfsStreamContent
|
||||
*/
|
||||
public function chgrp($group);
|
||||
|
||||
/**
|
||||
* checks whether file is owned by group
|
||||
*
|
||||
* @param int $group
|
||||
* @return bool
|
||||
*/
|
||||
public function isOwnedByGroup($group);
|
||||
|
||||
/**
|
||||
* returns owner group of file
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getGroup();
|
||||
|
||||
/**
|
||||
* sets parent path
|
||||
*
|
||||
* @param string $parentPath
|
||||
* @internal only to be set by parent
|
||||
* @since 1.2.0
|
||||
*/
|
||||
public function setParentPath($parentPath);
|
||||
|
||||
/**
|
||||
* returns path to this content
|
||||
*
|
||||
* @return string
|
||||
* @since 1.2.0
|
||||
*/
|
||||
public function path();
|
||||
|
||||
/**
|
||||
* returns complete vfsStream url for this content
|
||||
*
|
||||
* @return string
|
||||
* @since 1.2.0
|
||||
*/
|
||||
public function url();
|
||||
}
|
||||
?>
|
267
core/vendor/mikey179/vfsStream/src/main/php/org/bovigo/vfs/vfsStreamDirectory.php
vendored
Normal file
267
core/vendor/mikey179/vfsStream/src/main/php/org/bovigo/vfs/vfsStreamDirectory.php
vendored
Normal file
|
@ -0,0 +1,267 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of vfsStream.
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @package org\bovigo\vfs
|
||||
*/
|
||||
namespace org\bovigo\vfs;
|
||||
/**
|
||||
* Directory container.
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
class vfsStreamDirectory extends vfsStreamAbstractContent implements vfsStreamContainer
|
||||
{
|
||||
/**
|
||||
* list of directory children
|
||||
*
|
||||
* @type vfsStreamContent[]
|
||||
*/
|
||||
protected $children = array();
|
||||
|
||||
/**
|
||||
* constructor
|
||||
*
|
||||
* @param string $name
|
||||
* @param int $permissions optional
|
||||
* @throws vfsStreamException
|
||||
*/
|
||||
public function __construct($name, $permissions = null)
|
||||
{
|
||||
if (strstr($name, '/') !== false) {
|
||||
throw new vfsStreamException('Directory name can not contain /.');
|
||||
}
|
||||
|
||||
$this->type = vfsStreamContent::TYPE_DIR;
|
||||
parent::__construct($name, $permissions);
|
||||
}
|
||||
|
||||
/**
|
||||
* returns default permissions for concrete implementation
|
||||
*
|
||||
* @return int
|
||||
* @since 0.8.0
|
||||
*/
|
||||
protected function getDefaultPermissions()
|
||||
{
|
||||
return 0777;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns size of directory
|
||||
*
|
||||
* The size of a directory is always 0 bytes. To calculate the summarized
|
||||
* size of all children in the directory use sizeSummarized().
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function size()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns summarized size of directory and its children
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function sizeSummarized()
|
||||
{
|
||||
$size = 0;
|
||||
foreach ($this->children as $child) {
|
||||
if ($child->getType() === vfsStreamContent::TYPE_DIR) {
|
||||
$size += $child->sizeSummarized();
|
||||
} else {
|
||||
$size += $child->size();
|
||||
}
|
||||
}
|
||||
|
||||
return $size;
|
||||
}
|
||||
|
||||
/**
|
||||
* renames the content
|
||||
*
|
||||
* @param string $newName
|
||||
* @throws vfsStreamException
|
||||
*/
|
||||
public function rename($newName)
|
||||
{
|
||||
if (strstr($newName, '/') !== false) {
|
||||
throw new vfsStreamException('Directory name can not contain /.');
|
||||
}
|
||||
|
||||
parent::rename($newName);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* sets parent path
|
||||
*
|
||||
* @param string $parentPath
|
||||
* @internal only to be set by parent
|
||||
* @since 1.2.0
|
||||
*/
|
||||
public function setParentPath($parentPath)
|
||||
{
|
||||
parent::setParentPath($parentPath);
|
||||
foreach ($this->children as $child) {
|
||||
$child->setParentPath($this->path());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* adds child to the directory
|
||||
*
|
||||
* @param vfsStreamContent $child
|
||||
*/
|
||||
public function addChild(vfsStreamContent $child)
|
||||
{
|
||||
$child->setParentPath($this->path());
|
||||
$this->children[$child->getName()] = $child;
|
||||
$this->updateModifications();
|
||||
}
|
||||
|
||||
/**
|
||||
* removes child from the directory
|
||||
*
|
||||
* @param string $name
|
||||
* @return bool
|
||||
*/
|
||||
public function removeChild($name)
|
||||
{
|
||||
foreach ($this->children as $key => $child) {
|
||||
if ($child->appliesTo($name)) {
|
||||
$child->setParentPath(null);
|
||||
unset($this->children[$key]);
|
||||
$this->updateModifications();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* updates internal timestamps
|
||||
*/
|
||||
protected function updateModifications()
|
||||
{
|
||||
$time = time();
|
||||
$this->lastAttributeModified = $time;
|
||||
$this->lastModified = $time;
|
||||
}
|
||||
|
||||
/**
|
||||
* checks whether the container contains a child with the given name
|
||||
*
|
||||
* @param string $name
|
||||
* @return bool
|
||||
*/
|
||||
public function hasChild($name)
|
||||
{
|
||||
return ($this->getChild($name) !== null);
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the child with the given name
|
||||
*
|
||||
* @param string $name
|
||||
* @return vfsStreamContent
|
||||
*/
|
||||
public function getChild($name)
|
||||
{
|
||||
$childName = $this->getRealChildName($name);
|
||||
foreach ($this->children as $child) {
|
||||
if ($child->getName() === $childName) {
|
||||
return $child;
|
||||
}
|
||||
|
||||
if ($child->appliesTo($childName) === true && $child->hasChild($childName) === true) {
|
||||
return $child->getChild($childName);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* helper method to detect the real child name
|
||||
*
|
||||
* @param string $name
|
||||
* @return string
|
||||
*/
|
||||
protected function getRealChildName($name)
|
||||
{
|
||||
if ($this->appliesTo($name) === true) {
|
||||
return self::getChildName($name, $this->name);
|
||||
}
|
||||
|
||||
return $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* helper method to calculate the child name
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $ownName
|
||||
* @return string
|
||||
*/
|
||||
protected static function getChildName($name, $ownName)
|
||||
{
|
||||
if ($name === $ownName) {
|
||||
return $name;
|
||||
}
|
||||
|
||||
return substr($name, strlen($ownName) + 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* checks whether directory contains any children
|
||||
*
|
||||
* @return bool
|
||||
* @since 0.10.0
|
||||
*/
|
||||
public function hasChildren()
|
||||
{
|
||||
return (count($this->children) > 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* returns a list of children for this directory
|
||||
*
|
||||
* @return vfsStreamContent[]
|
||||
*/
|
||||
public function getChildren()
|
||||
{
|
||||
return array_values($this->children);
|
||||
}
|
||||
|
||||
/**
|
||||
* returns iterator for the children
|
||||
*
|
||||
* @return vfsStreamContainerIterator
|
||||
*/
|
||||
public function getIterator()
|
||||
{
|
||||
return new vfsStreamContainerIterator($this->children);
|
||||
}
|
||||
|
||||
/**
|
||||
* checks whether dir is a dot dir
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isDot()
|
||||
{
|
||||
if ('.' === $this->name || '..' === $this->name) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
?>
|
20
core/vendor/mikey179/vfsStream/src/main/php/org/bovigo/vfs/vfsStreamException.php
vendored
Normal file
20
core/vendor/mikey179/vfsStream/src/main/php/org/bovigo/vfs/vfsStreamException.php
vendored
Normal file
|
@ -0,0 +1,20 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of vfsStream.
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @package org\bovigo\vfs
|
||||
*/
|
||||
namespace org\bovigo\vfs;
|
||||
/**
|
||||
* Exception for vfsStream errors.
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
class vfsStreamException extends \Exception
|
||||
{
|
||||
// intentionally empty
|
||||
}
|
||||
?>
|
394
core/vendor/mikey179/vfsStream/src/main/php/org/bovigo/vfs/vfsStreamFile.php
vendored
Normal file
394
core/vendor/mikey179/vfsStream/src/main/php/org/bovigo/vfs/vfsStreamFile.php
vendored
Normal file
|
@ -0,0 +1,394 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of vfsStream.
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @package org\bovigo\vfs
|
||||
*/
|
||||
namespace org\bovigo\vfs;
|
||||
use org\bovigo\vfs\content\FileContent;
|
||||
use org\bovigo\vfs\content\StringBasedFileContent;
|
||||
/**
|
||||
* File container.
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
class vfsStreamFile extends vfsStreamAbstractContent
|
||||
{
|
||||
/**
|
||||
* content of the file
|
||||
*
|
||||
* @type FileContent
|
||||
*/
|
||||
private $content;
|
||||
/**
|
||||
* Resource id which exclusively locked this file
|
||||
*
|
||||
* @type string
|
||||
*/
|
||||
protected $exclusiveLock;
|
||||
/**
|
||||
* Resources ids which currently holds shared lock to this file
|
||||
*
|
||||
* @type bool[string]
|
||||
*/
|
||||
protected $sharedLock = array();
|
||||
|
||||
/**
|
||||
* constructor
|
||||
*
|
||||
* @param string $name
|
||||
* @param int $permissions optional
|
||||
*/
|
||||
public function __construct($name, $permissions = null)
|
||||
{
|
||||
$this->content = new StringBasedFileContent(null);
|
||||
$this->type = vfsStreamContent::TYPE_FILE;
|
||||
parent::__construct($name, $permissions);
|
||||
}
|
||||
|
||||
/**
|
||||
* returns default permissions for concrete implementation
|
||||
*
|
||||
* @return int
|
||||
* @since 0.8.0
|
||||
*/
|
||||
protected function getDefaultPermissions()
|
||||
{
|
||||
return 0666;
|
||||
}
|
||||
|
||||
/**
|
||||
* checks whether the container can be applied to given name
|
||||
*
|
||||
* @param string $name
|
||||
* @return bool
|
||||
*/
|
||||
public function appliesTo($name)
|
||||
{
|
||||
return ($name === $this->name);
|
||||
}
|
||||
|
||||
/**
|
||||
* alias for withContent()
|
||||
*
|
||||
* @param string $content
|
||||
* @return vfsStreamFile
|
||||
* @see withContent()
|
||||
*/
|
||||
public function setContent($content)
|
||||
{
|
||||
return $this->withContent($content);
|
||||
}
|
||||
|
||||
/**
|
||||
* sets the contents of the file
|
||||
*
|
||||
* Setting content with this method does not change the time when the file
|
||||
* was last modified.
|
||||
*
|
||||
* @param string]FileContent $content
|
||||
* @return vfsStreamFile
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function withContent($content)
|
||||
{
|
||||
if (is_string($content)) {
|
||||
$this->content = new StringBasedFileContent($content);
|
||||
} elseif ($content instanceof FileContent) {
|
||||
$this->content = $content;
|
||||
} else {
|
||||
throw new \InvalidArgumentException('Given content must either be a string or an instance of org\bovigo\vfs\content\FileContent');
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the contents of the file
|
||||
*
|
||||
* Getting content does not change the time when the file
|
||||
* was last accessed.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getContent()
|
||||
{
|
||||
return $this->content->content();
|
||||
}
|
||||
|
||||
/**
|
||||
* simply open the file
|
||||
*
|
||||
* @since 0.9
|
||||
*/
|
||||
public function open()
|
||||
{
|
||||
$this->content->seek(0, SEEK_SET);
|
||||
$this->lastAccessed = time();
|
||||
}
|
||||
|
||||
/**
|
||||
* open file and set pointer to end of file
|
||||
*
|
||||
* @since 0.9
|
||||
*/
|
||||
public function openForAppend()
|
||||
{
|
||||
$this->content->seek(0, SEEK_END);
|
||||
$this->lastAccessed = time();
|
||||
}
|
||||
|
||||
/**
|
||||
* open file and truncate content
|
||||
*
|
||||
* @since 0.9
|
||||
*/
|
||||
public function openWithTruncate()
|
||||
{
|
||||
$this->open();
|
||||
$this->content->truncate(0);
|
||||
$time = time();
|
||||
$this->lastAccessed = $time;
|
||||
$this->lastModified = $time;
|
||||
}
|
||||
|
||||
/**
|
||||
* reads the given amount of bytes from content
|
||||
*
|
||||
* Using this method changes the time when the file was last accessed.
|
||||
*
|
||||
* @param int $count
|
||||
* @return string
|
||||
*/
|
||||
public function read($count)
|
||||
{
|
||||
$this->lastAccessed = time();
|
||||
return $this->content->read($count);
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the content until its end from current offset
|
||||
*
|
||||
* Using this method changes the time when the file was last accessed.
|
||||
*
|
||||
* @return string
|
||||
* @deprecated since 1.3.0
|
||||
*/
|
||||
public function readUntilEnd()
|
||||
{
|
||||
$this->lastAccessed = time();
|
||||
return $this->content->readUntilEnd();
|
||||
}
|
||||
|
||||
/**
|
||||
* writes an amount of data
|
||||
*
|
||||
* Using this method changes the time when the file was last modified.
|
||||
*
|
||||
* @param string $data
|
||||
* @return amount of written bytes
|
||||
*/
|
||||
public function write($data)
|
||||
{
|
||||
$this->lastModified = time();
|
||||
return $this->content->write($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Truncates a file to a given length
|
||||
*
|
||||
* @param int $size length to truncate file to
|
||||
* @return bool
|
||||
* @since 1.1.0
|
||||
*/
|
||||
public function truncate($size)
|
||||
{
|
||||
$this->content->truncate($size);
|
||||
$this->lastModified = time();
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* checks whether pointer is at end of file
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function eof()
|
||||
{
|
||||
return $this->content->eof();
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the current position within the file
|
||||
*
|
||||
* @return int
|
||||
* @deprecated since 1.3.0
|
||||
*/
|
||||
public function getBytesRead()
|
||||
{
|
||||
return $this->content->bytesRead();
|
||||
}
|
||||
|
||||
/**
|
||||
* seeks to the given offset
|
||||
*
|
||||
* @param int $offset
|
||||
* @param int $whence
|
||||
* @return bool
|
||||
*/
|
||||
public function seek($offset, $whence)
|
||||
{
|
||||
return $this->content->seek($offset, $whence);
|
||||
}
|
||||
|
||||
/**
|
||||
* returns size of content
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function size()
|
||||
{
|
||||
return $this->content->size();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* locks file for
|
||||
*
|
||||
* @param resource|vfsStreamWrapper $resource
|
||||
* @param int $operation
|
||||
* @return bool
|
||||
* @since 0.10.0
|
||||
* @see https://github.com/mikey179/vfsStream/issues/6
|
||||
* @see https://github.com/mikey179/vfsStream/issues/40
|
||||
*/
|
||||
public function lock($resource, $operation)
|
||||
{
|
||||
if ((LOCK_NB & $operation) == LOCK_NB) {
|
||||
$operation = $operation - LOCK_NB;
|
||||
}
|
||||
|
||||
// call to lock file on the same file handler firstly releases the lock
|
||||
$this->unlock($resource);
|
||||
|
||||
if (LOCK_EX === $operation) {
|
||||
if ($this->isLocked()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->setExclusiveLock($resource);
|
||||
} elseif(LOCK_SH === $operation) {
|
||||
if ($this->hasExclusiveLock()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->addSharedLock($resource);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes lock from file acquired by given resource
|
||||
*
|
||||
* @param resource|vfsStreamWrapper $resource
|
||||
* @see https://github.com/mikey179/vfsStream/issues/40
|
||||
*/
|
||||
public function unlock($resource) {
|
||||
if ($this->hasExclusiveLock($resource)) {
|
||||
$this->exclusiveLock = null;
|
||||
}
|
||||
if ($this->hasSharedLock($resource)) {
|
||||
unset($this->sharedLock[$this->getResourceId($resource)]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set exlusive lock on file by given resource
|
||||
*
|
||||
* @param resource|vfsStreamWrapper $resource
|
||||
* @see https://github.com/mikey179/vfsStream/issues/40
|
||||
*/
|
||||
protected function setExclusiveLock($resource) {
|
||||
$this->exclusiveLock = $this->getResourceId($resource);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add shared lock on file by given resource
|
||||
*
|
||||
* @param resource|vfsStreamWrapper $resource
|
||||
* @see https://github.com/mikey179/vfsStream/issues/40
|
||||
*/
|
||||
protected function addSharedLock($resource) {
|
||||
$this->sharedLock[$this->getResourceId($resource)] = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* checks whether file is locked
|
||||
*
|
||||
* @param resource|vfsStreamWrapper $resource
|
||||
* @return bool
|
||||
* @since 0.10.0
|
||||
* @see https://github.com/mikey179/vfsStream/issues/6
|
||||
* @see https://github.com/mikey179/vfsStream/issues/40
|
||||
*/
|
||||
public function isLocked($resource = null)
|
||||
{
|
||||
return $this->hasSharedLock($resource) || $this->hasExclusiveLock($resource);
|
||||
}
|
||||
|
||||
/**
|
||||
* checks whether file is locked in shared mode
|
||||
*
|
||||
* @param resource|vfsStreamWrapper $resource
|
||||
* @return bool
|
||||
* @since 0.10.0
|
||||
* @see https://github.com/mikey179/vfsStream/issues/6
|
||||
* @see https://github.com/mikey179/vfsStream/issues/40
|
||||
*/
|
||||
public function hasSharedLock($resource = null)
|
||||
{
|
||||
if (null !== $resource) {
|
||||
return isset($this->sharedLock[$this->getResourceId($resource)]);
|
||||
}
|
||||
|
||||
return !empty($this->sharedLock);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns unique resource id
|
||||
*
|
||||
* @param resource|vfsStreamWrapper $resource
|
||||
* @return string
|
||||
* @see https://github.com/mikey179/vfsStream/issues/40
|
||||
*/
|
||||
public function getResourceId($resource) {
|
||||
if (is_resource($resource)) {
|
||||
$data = stream_get_meta_data($resource);
|
||||
$resource = $data['wrapper_data'];
|
||||
}
|
||||
|
||||
return spl_object_hash($resource);
|
||||
}
|
||||
|
||||
/**
|
||||
* checks whether file is locked in exclusive mode
|
||||
*
|
||||
* @param resource|vfsStreamWrapper $resource
|
||||
* @return bool
|
||||
* @since 0.10.0
|
||||
* @see https://github.com/mikey179/vfsStream/issues/6
|
||||
* @see https://github.com/mikey179/vfsStream/issues/40
|
||||
*/
|
||||
public function hasExclusiveLock($resource = null)
|
||||
{
|
||||
if (null !== $resource) {
|
||||
return $this->exclusiveLock === $this->getResourceId($resource);
|
||||
}
|
||||
|
||||
return null !== $this->exclusiveLock;
|
||||
}
|
||||
}
|
986
core/vendor/mikey179/vfsStream/src/main/php/org/bovigo/vfs/vfsStreamWrapper.php
vendored
Normal file
986
core/vendor/mikey179/vfsStream/src/main/php/org/bovigo/vfs/vfsStreamWrapper.php
vendored
Normal file
|
@ -0,0 +1,986 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of vfsStream.
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @package org\bovigo\vfs
|
||||
*/
|
||||
namespace org\bovigo\vfs;
|
||||
/**
|
||||
* Stream wrapper to mock file system requests.
|
||||
*/
|
||||
class vfsStreamWrapper
|
||||
{
|
||||
/**
|
||||
* open file for reading
|
||||
*/
|
||||
const READ = 'r';
|
||||
/**
|
||||
* truncate file
|
||||
*/
|
||||
const TRUNCATE = 'w';
|
||||
/**
|
||||
* set file pointer to end, append new data
|
||||
*/
|
||||
const APPEND = 'a';
|
||||
/**
|
||||
* set file pointer to start, overwrite existing data
|
||||
*/
|
||||
const WRITE = 'x';
|
||||
/**
|
||||
* set file pointer to start, overwrite existing data; or create file if
|
||||
* does not exist
|
||||
*/
|
||||
const WRITE_NEW = 'c';
|
||||
/**
|
||||
* file mode: read only
|
||||
*/
|
||||
const READONLY = 0;
|
||||
/**
|
||||
* file mode: write only
|
||||
*/
|
||||
const WRITEONLY = 1;
|
||||
/**
|
||||
* file mode: read and write
|
||||
*/
|
||||
const ALL = 2;
|
||||
/**
|
||||
* switch whether class has already been registered as stream wrapper or not
|
||||
*
|
||||
* @type bool
|
||||
*/
|
||||
protected static $registered = false;
|
||||
/**
|
||||
* root content
|
||||
*
|
||||
* @type vfsStreamContent
|
||||
*/
|
||||
protected static $root;
|
||||
/**
|
||||
* disk space quota
|
||||
*
|
||||
* @type Quota
|
||||
*/
|
||||
private static $quota;
|
||||
/**
|
||||
* file mode: read only, write only, all
|
||||
*
|
||||
* @type int
|
||||
*/
|
||||
protected $mode;
|
||||
/**
|
||||
* shortcut to file container
|
||||
*
|
||||
* @type vfsStreamFile
|
||||
*/
|
||||
protected $content;
|
||||
/**
|
||||
* shortcut to directory container
|
||||
*
|
||||
* @type vfsStreamDirectory
|
||||
*/
|
||||
protected $dir;
|
||||
/**
|
||||
* shortcut to directory container iterator
|
||||
*
|
||||
* @type vfsStreamDirectory
|
||||
*/
|
||||
protected $dirIterator;
|
||||
|
||||
/**
|
||||
* method to register the stream wrapper
|
||||
*
|
||||
* Please be aware that a call to this method will reset the root element
|
||||
* to null.
|
||||
* If the stream is already registered the method returns silently. If there
|
||||
* is already another stream wrapper registered for the scheme used by
|
||||
* vfsStream a vfsStreamException will be thrown.
|
||||
*
|
||||
* @throws vfsStreamException
|
||||
*/
|
||||
public static function register()
|
||||
{
|
||||
self::$root = null;
|
||||
self::$quota = Quota::unlimited();
|
||||
if (true === self::$registered) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (@stream_wrapper_register(vfsStream::SCHEME, __CLASS__) === false) {
|
||||
throw new vfsStreamException('A handler has already been registered for the ' . vfsStream::SCHEME . ' protocol.');
|
||||
}
|
||||
|
||||
self::$registered = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* sets the root content
|
||||
*
|
||||
* @param vfsStreamContainer $root
|
||||
* @return vfsStreamContainer
|
||||
*/
|
||||
public static function setRoot(vfsStreamContainer $root)
|
||||
{
|
||||
self::$root = $root;
|
||||
clearstatcache();
|
||||
return self::$root;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the root content
|
||||
*
|
||||
* @return vfsStreamContainer
|
||||
*/
|
||||
public static function getRoot()
|
||||
{
|
||||
return self::$root;
|
||||
}
|
||||
|
||||
/**
|
||||
* sets quota for disk space
|
||||
*
|
||||
* @param Quota $quota
|
||||
* @since 1.1.0
|
||||
*/
|
||||
public static function setQuota(Quota $quota)
|
||||
{
|
||||
self::$quota = $quota;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns content for given path
|
||||
*
|
||||
* @param string $path
|
||||
* @return vfsStreamContent
|
||||
*/
|
||||
protected function getContent($path)
|
||||
{
|
||||
if (null === self::$root) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (self::$root->getName() === $path) {
|
||||
return self::$root;
|
||||
}
|
||||
|
||||
if ($this->isInRoot($path) && self::$root->hasChild($path) === true) {
|
||||
return self::$root->getChild($path);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* helper method to detect whether given path is in root path
|
||||
*
|
||||
* @param string $path
|
||||
* @return bool
|
||||
*/
|
||||
private function isInRoot($path)
|
||||
{
|
||||
return substr($path, 0, strlen(self::$root->getName())) === self::$root->getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* returns content for given path but only when it is of given type
|
||||
*
|
||||
* @param string $path
|
||||
* @param int $type
|
||||
* @return vfsStreamContent
|
||||
*/
|
||||
protected function getContentOfType($path, $type)
|
||||
{
|
||||
$content = $this->getContent($path);
|
||||
if (null !== $content && $content->getType() === $type) {
|
||||
return $content;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* splits path into its dirname and the basename
|
||||
*
|
||||
* @param string $path
|
||||
* @return string[]
|
||||
*/
|
||||
protected function splitPath($path)
|
||||
{
|
||||
$lastSlashPos = strrpos($path, '/');
|
||||
if (false === $lastSlashPos) {
|
||||
return array('dirname' => '', 'basename' => $path);
|
||||
}
|
||||
|
||||
return array('dirname' => substr($path, 0, $lastSlashPos),
|
||||
'basename' => substr($path, $lastSlashPos + 1)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* helper method to resolve a path from /foo/bar/. to /foo/bar
|
||||
*
|
||||
* @param string $path
|
||||
* @return string
|
||||
*/
|
||||
protected function resolvePath($path)
|
||||
{
|
||||
$newPath = array();
|
||||
foreach (explode('/', $path) as $pathPart) {
|
||||
if ('.' !== $pathPart) {
|
||||
if ('..' !== $pathPart) {
|
||||
$newPath[] = $pathPart;
|
||||
} else {
|
||||
array_pop($newPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return implode('/', $newPath);
|
||||
}
|
||||
|
||||
/**
|
||||
* open the stream
|
||||
*
|
||||
* @param string $path the path to open
|
||||
* @param string $mode mode for opening
|
||||
* @param string $options options for opening
|
||||
* @param string $opened_path full path that was actually opened
|
||||
* @return bool
|
||||
*/
|
||||
public function stream_open($path, $mode, $options, $opened_path)
|
||||
{
|
||||
$extended = ((strstr($mode, '+') !== false) ? (true) : (false));
|
||||
$mode = str_replace(array('t', 'b', '+'), '', $mode);
|
||||
if (in_array($mode, array('r', 'w', 'a', 'x', 'c')) === false) {
|
||||
if (($options & STREAM_REPORT_ERRORS) === STREAM_REPORT_ERRORS) {
|
||||
trigger_error('Illegal mode ' . $mode . ', use r, w, a, x or c, flavoured with t, b and/or +', E_USER_WARNING);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->mode = $this->calculateMode($mode, $extended);
|
||||
$path = $this->resolvePath(vfsStream::path($path));
|
||||
$this->content = $this->getContentOfType($path, vfsStreamContent::TYPE_FILE);
|
||||
if (null !== $this->content) {
|
||||
if (self::WRITE === $mode) {
|
||||
if (($options & STREAM_REPORT_ERRORS) === STREAM_REPORT_ERRORS) {
|
||||
trigger_error('File ' . $path . ' already exists, can not open with mode x', E_USER_WARNING);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (
|
||||
(self::TRUNCATE === $mode || self::APPEND === $mode) &&
|
||||
$this->content->isWritable(vfsStream::getCurrentUser(), vfsStream::getCurrentGroup()) === false
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (self::TRUNCATE === $mode) {
|
||||
$this->content->openWithTruncate();
|
||||
} elseif (self::APPEND === $mode) {
|
||||
$this->content->openForAppend();
|
||||
} else {
|
||||
if (!$this->content->isReadable(vfsStream::getCurrentUser(), vfsStream::getCurrentGroup())) {
|
||||
if (($options & STREAM_REPORT_ERRORS) === STREAM_REPORT_ERRORS) {
|
||||
trigger_error('Permission denied', E_USER_WARNING);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
$this->content->open();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
$content = $this->createFile($path, $mode, $options);
|
||||
if (false === $content) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->content = $content;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* creates a file at given path
|
||||
*
|
||||
* @param string $path the path to open
|
||||
* @param string $mode mode for opening
|
||||
* @param string $options options for opening
|
||||
* @return bool
|
||||
*/
|
||||
private function createFile($path, $mode = null, $options = null)
|
||||
{
|
||||
$names = $this->splitPath($path);
|
||||
if (empty($names['dirname']) === true) {
|
||||
if (($options & STREAM_REPORT_ERRORS) === STREAM_REPORT_ERRORS) {
|
||||
trigger_error('File ' . $names['basename'] . ' does not exist', E_USER_WARNING);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
$dir = $this->getContentOfType($names['dirname'], vfsStreamContent::TYPE_DIR);
|
||||
if (null === $dir) {
|
||||
if (($options & STREAM_REPORT_ERRORS) === STREAM_REPORT_ERRORS) {
|
||||
trigger_error('Directory ' . $names['dirname'] . ' does not exist', E_USER_WARNING);
|
||||
}
|
||||
|
||||
return false;
|
||||
} elseif ($dir->hasChild($names['basename']) === true) {
|
||||
if (($options & STREAM_REPORT_ERRORS) === STREAM_REPORT_ERRORS) {
|
||||
trigger_error('Directory ' . $names['dirname'] . ' already contains a director named ' . $names['basename'], E_USER_WARNING);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (self::READ === $mode) {
|
||||
if (($options & STREAM_REPORT_ERRORS) === STREAM_REPORT_ERRORS) {
|
||||
trigger_error('Can not open non-existing file ' . $path . ' for reading', E_USER_WARNING);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($dir->isWritable(vfsStream::getCurrentUser(), vfsStream::getCurrentGroup()) === false) {
|
||||
if (($options & STREAM_REPORT_ERRORS) === STREAM_REPORT_ERRORS) {
|
||||
trigger_error('Can not create new file in non-writable path ' . $names['dirname'], E_USER_WARNING);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return vfsStream::newFile($names['basename'])->at($dir);
|
||||
}
|
||||
|
||||
/**
|
||||
* calculates the file mode
|
||||
*
|
||||
* @param string $mode opening mode: r, w, a or x
|
||||
* @param bool $extended true if + was set with opening mode
|
||||
* @return int
|
||||
*/
|
||||
protected function calculateMode($mode, $extended)
|
||||
{
|
||||
if (true === $extended) {
|
||||
return self::ALL;
|
||||
}
|
||||
|
||||
if (self::READ === $mode) {
|
||||
return self::READONLY;
|
||||
}
|
||||
|
||||
return self::WRITEONLY;
|
||||
}
|
||||
|
||||
/**
|
||||
* closes the stream
|
||||
*
|
||||
* @see https://github.com/mikey179/vfsStream/issues/40
|
||||
*/
|
||||
public function stream_close()
|
||||
{
|
||||
$this->content->lock($this, LOCK_UN);
|
||||
}
|
||||
|
||||
/**
|
||||
* read the stream up to $count bytes
|
||||
*
|
||||
* @param int $count amount of bytes to read
|
||||
* @return string
|
||||
*/
|
||||
public function stream_read($count)
|
||||
{
|
||||
if (self::WRITEONLY === $this->mode) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if ($this->content->isReadable(vfsStream::getCurrentUser(), vfsStream::getCurrentGroup()) === false) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return $this->content->read($count);
|
||||
}
|
||||
|
||||
/**
|
||||
* writes data into the stream
|
||||
*
|
||||
* @param string $data
|
||||
* @return int amount of bytes written
|
||||
*/
|
||||
public function stream_write($data)
|
||||
{
|
||||
if (self::READONLY === $this->mode) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ($this->content->isWritable(vfsStream::getCurrentUser(), vfsStream::getCurrentGroup()) === false) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (self::$quota->isLimited()) {
|
||||
$data = substr($data, 0, self::$quota->spaceLeft(self::$root->sizeSummarized()));
|
||||
}
|
||||
|
||||
return $this->content->write($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* truncates a file to a given length
|
||||
*
|
||||
* @param int $size length to truncate file to
|
||||
* @return bool
|
||||
* @since 1.1.0
|
||||
*/
|
||||
public function stream_truncate($size)
|
||||
{
|
||||
if (self::READONLY === $this->mode) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($this->content->isWritable(vfsStream::getCurrentUser(), vfsStream::getCurrentGroup()) === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($this->content->getType() !== vfsStreamContent::TYPE_FILE) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (self::$quota->isLimited() && $this->content->size() < $size) {
|
||||
$maxSize = self::$quota->spaceLeft(self::$root->sizeSummarized());
|
||||
if (0 === $maxSize) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($size > $maxSize) {
|
||||
$size = $maxSize;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->content->truncate($size);
|
||||
}
|
||||
|
||||
/**
|
||||
* sets metadata like owner, user or permissions
|
||||
*
|
||||
* @param string $path
|
||||
* @param int $option
|
||||
* @param mixed $var
|
||||
* @return bool
|
||||
* @since 1.1.0
|
||||
*/
|
||||
public function stream_metadata($path, $option, $var)
|
||||
{
|
||||
$path = $this->resolvePath(vfsStream::path($path));
|
||||
$content = $this->getContent($path);
|
||||
switch ($option) {
|
||||
case STREAM_META_TOUCH:
|
||||
if (null === $content) {
|
||||
$content = $this->createFile($path, null, STREAM_REPORT_ERRORS);
|
||||
// file creation may not be allowed at provided path
|
||||
if (false === $content) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$currentTime = time();
|
||||
$content->lastModified(((isset($var[0])) ? ($var[0]) : ($currentTime)))
|
||||
->lastAccessed(((isset($var[1])) ? ($var[1]) : ($currentTime)));
|
||||
return true;
|
||||
|
||||
case STREAM_META_OWNER_NAME:
|
||||
return false;
|
||||
|
||||
case STREAM_META_OWNER:
|
||||
if (null === $content) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->doPermChange($path,
|
||||
$content,
|
||||
function() use ($content, $var)
|
||||
{
|
||||
$content->chown($var);
|
||||
}
|
||||
);
|
||||
|
||||
case STREAM_META_GROUP_NAME:
|
||||
return false;
|
||||
|
||||
case STREAM_META_GROUP:
|
||||
if (null === $content) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->doPermChange($path,
|
||||
$content,
|
||||
function() use ($content, $var)
|
||||
{
|
||||
$content->chgrp($var);
|
||||
}
|
||||
);
|
||||
|
||||
case STREAM_META_ACCESS:
|
||||
if (null === $content) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->doPermChange($path,
|
||||
$content,
|
||||
function() use ($content, $var)
|
||||
{
|
||||
$content->chmod($var);
|
||||
}
|
||||
);
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* executes given permission change when necessary rights allow such a change
|
||||
*
|
||||
* @param string $path
|
||||
* @param vfsStreamAbstractContent $content
|
||||
* @param \Closure $change
|
||||
* @return bool
|
||||
*/
|
||||
private function doPermChange($path, vfsStreamAbstractContent $content, \Closure $change)
|
||||
{
|
||||
if (!$content->isOwnedByUser(vfsStream::getCurrentUser())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (self::$root->getName() !== $path) {
|
||||
$names = $this->splitPath($path);
|
||||
$parent = $this->getContent($names['dirname']);
|
||||
if (!$parent->isWritable(vfsStream::getCurrentUser(), vfsStream::getCurrentGroup())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$change();
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* checks whether stream is at end of file
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function stream_eof()
|
||||
{
|
||||
return $this->content->eof();
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the current position of the stream
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function stream_tell()
|
||||
{
|
||||
return $this->content->getBytesRead();
|
||||
}
|
||||
|
||||
/**
|
||||
* seeks to the given offset
|
||||
*
|
||||
* @param int $offset
|
||||
* @param int $whence
|
||||
* @return bool
|
||||
*/
|
||||
public function stream_seek($offset, $whence)
|
||||
{
|
||||
return $this->content->seek($offset, $whence);
|
||||
}
|
||||
|
||||
/**
|
||||
* flushes unstored data into storage
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function stream_flush()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns status of stream
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function stream_stat()
|
||||
{
|
||||
$fileStat = array('dev' => 0,
|
||||
'ino' => 0,
|
||||
'mode' => $this->content->getType() | $this->content->getPermissions(),
|
||||
'nlink' => 0,
|
||||
'uid' => $this->content->getUser(),
|
||||
'gid' => $this->content->getGroup(),
|
||||
'rdev' => 0,
|
||||
'size' => $this->content->size(),
|
||||
'atime' => $this->content->fileatime(),
|
||||
'mtime' => $this->content->filemtime(),
|
||||
'ctime' => $this->content->filectime(),
|
||||
'blksize' => -1,
|
||||
'blocks' => -1
|
||||
);
|
||||
return array_merge(array_values($fileStat), $fileStat);
|
||||
}
|
||||
|
||||
/**
|
||||
* retrieve the underlaying resource
|
||||
*
|
||||
* Please note that this method always returns false as there is no
|
||||
* underlaying resource to return.
|
||||
*
|
||||
* @param int $cast_as
|
||||
* @since 0.9.0
|
||||
* @see https://github.com/mikey179/vfsStream/issues/3
|
||||
* @return bool
|
||||
*/
|
||||
public function stream_cast($cast_as)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* set lock status for stream
|
||||
*
|
||||
* @param int $operation
|
||||
* @return bool
|
||||
* @since 0.10.0
|
||||
* @see https://github.com/mikey179/vfsStream/issues/6
|
||||
* @see https://github.com/mikey179/vfsStream/issues/31
|
||||
* @see https://github.com/mikey179/vfsStream/issues/40
|
||||
*/
|
||||
public function stream_lock($operation)
|
||||
{
|
||||
if ((LOCK_NB & $operation) == LOCK_NB) {
|
||||
$operation = $operation - LOCK_NB;
|
||||
}
|
||||
|
||||
return $this->content->lock($this, $operation);
|
||||
}
|
||||
|
||||
/**
|
||||
* sets options on the stream
|
||||
*
|
||||
* @param int $option key of option to set
|
||||
* @param int $arg1
|
||||
* @param int $arg2
|
||||
* @return bool
|
||||
* @since 0.10.0
|
||||
* @see https://github.com/mikey179/vfsStream/issues/15
|
||||
* @see http://www.php.net/manual/streamwrapper.stream-set-option.php
|
||||
*/
|
||||
public function stream_set_option($option, $arg1, $arg2)
|
||||
{
|
||||
switch ($option) {
|
||||
case STREAM_OPTION_BLOCKING:
|
||||
// break omitted
|
||||
|
||||
case STREAM_OPTION_READ_TIMEOUT:
|
||||
// break omitted
|
||||
|
||||
case STREAM_OPTION_WRITE_BUFFER:
|
||||
// break omitted
|
||||
|
||||
default:
|
||||
// nothing to do here
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* remove the data under the given path
|
||||
*
|
||||
* @param string $path
|
||||
* @return bool
|
||||
*/
|
||||
public function unlink($path)
|
||||
{
|
||||
$realPath = $this->resolvePath(vfsStream::path($path));
|
||||
$content = $this->getContent($realPath);
|
||||
if (null === $content) {
|
||||
trigger_error('unlink(' . $path . '): No such file or directory', E_USER_WARNING);
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($content->getType() !== vfsStreamContent::TYPE_FILE) {
|
||||
trigger_error('unlink(' . $path . '): Operation not permitted', E_USER_WARNING);
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->doUnlink($realPath);
|
||||
}
|
||||
|
||||
/**
|
||||
* removes a path
|
||||
*
|
||||
* @param string $path
|
||||
* @return bool
|
||||
*/
|
||||
protected function doUnlink($path)
|
||||
{
|
||||
if (self::$root->getName() === $path) {
|
||||
// delete root? very brave. :)
|
||||
self::$root = null;
|
||||
clearstatcache();
|
||||
return true;
|
||||
}
|
||||
|
||||
$names = $this->splitPath($path);
|
||||
$content = $this->getContent($names['dirname']);
|
||||
if (!$content->isWritable(vfsStream::getCurrentUser(), vfsStream::getCurrentGroup())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
clearstatcache();
|
||||
return $content->removeChild($names['basename']);
|
||||
}
|
||||
|
||||
/**
|
||||
* rename from one path to another
|
||||
*
|
||||
* @param string $path_from
|
||||
* @param string $path_to
|
||||
* @return bool
|
||||
* @author Benoit Aubuchon
|
||||
*/
|
||||
public function rename($path_from, $path_to)
|
||||
{
|
||||
$srcRealPath = $this->resolvePath(vfsStream::path($path_from));
|
||||
$dstRealPath = $this->resolvePath(vfsStream::path($path_to));
|
||||
$srcContent = $this->getContent($srcRealPath);
|
||||
if (null == $srcContent) {
|
||||
trigger_error(' No such file or directory', E_USER_WARNING);
|
||||
return false;
|
||||
}
|
||||
$dstNames = $this->splitPath($dstRealPath);
|
||||
$dstParentContent = $this->getContent($dstNames['dirname']);
|
||||
if (null == $dstParentContent) {
|
||||
trigger_error('No such file or directory', E_USER_WARNING);
|
||||
return false;
|
||||
}
|
||||
if (!$dstParentContent->isWritable(vfsStream::getCurrentUser(), vfsStream::getCurrentGroup())) {
|
||||
trigger_error('Permission denied', E_USER_WARNING);
|
||||
return false;
|
||||
}
|
||||
if ($dstParentContent->getType() !== vfsStreamContent::TYPE_DIR) {
|
||||
trigger_error('Target is not a directory', E_USER_WARNING);
|
||||
return false;
|
||||
}
|
||||
|
||||
// remove old source first, so we can rename later
|
||||
// (renaming first would lead to not being able to remove the old path)
|
||||
if (!$this->doUnlink($srcRealPath)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$dstContent = $srcContent;
|
||||
// Renaming the filename
|
||||
$dstContent->rename($dstNames['basename']);
|
||||
// Copying to the destination
|
||||
$dstParentContent->addChild($dstContent);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* creates a new directory
|
||||
*
|
||||
* @param string $path
|
||||
* @param int $mode
|
||||
* @param int $options
|
||||
* @return bool
|
||||
*/
|
||||
public function mkdir($path, $mode, $options)
|
||||
{
|
||||
$umask = vfsStream::umask();
|
||||
if (0 < $umask) {
|
||||
$permissions = $mode & ~$umask;
|
||||
} else {
|
||||
$permissions = $mode;
|
||||
}
|
||||
|
||||
$path = $this->resolvePath(vfsStream::path($path));
|
||||
if (null !== $this->getContent($path)) {
|
||||
trigger_error('mkdir(): Path vfs://' . $path . ' exists', E_USER_WARNING);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (null === self::$root) {
|
||||
self::$root = vfsStream::newDirectory($path, $permissions);
|
||||
return true;
|
||||
}
|
||||
|
||||
$maxDepth = count(explode('/', $path));
|
||||
$names = $this->splitPath($path);
|
||||
$newDirs = $names['basename'];
|
||||
$dir = null;
|
||||
$i = 0;
|
||||
while ($dir === null && $i < $maxDepth) {
|
||||
$dir = $this->getContent($names['dirname']);
|
||||
$names = $this->splitPath($names['dirname']);
|
||||
if (null == $dir) {
|
||||
$newDirs = $names['basename'] . '/' . $newDirs;
|
||||
}
|
||||
|
||||
$i++;
|
||||
}
|
||||
|
||||
if (null === $dir
|
||||
|| $dir->getType() !== vfsStreamContent::TYPE_DIR
|
||||
|| $dir->isWritable(vfsStream::getCurrentUser(), vfsStream::getCurrentGroup()) === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$recursive = ((STREAM_MKDIR_RECURSIVE & $options) !== 0) ? (true) : (false);
|
||||
if (strpos($newDirs, '/') !== false && false === $recursive) {
|
||||
return false;
|
||||
}
|
||||
|
||||
vfsStream::newDirectory($newDirs, $permissions)->at($dir);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* removes a directory
|
||||
*
|
||||
* @param string $path
|
||||
* @param int $options
|
||||
* @return bool
|
||||
* @todo consider $options with STREAM_MKDIR_RECURSIVE
|
||||
*/
|
||||
public function rmdir($path, $options)
|
||||
{
|
||||
$path = $this->resolvePath(vfsStream::path($path));
|
||||
$child = $this->getContentOfType($path, vfsStreamContent::TYPE_DIR);
|
||||
if (null === $child) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// can only remove empty directories
|
||||
if (count($child->getChildren()) > 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (self::$root->getName() === $path) {
|
||||
// delete root? very brave. :)
|
||||
self::$root = null;
|
||||
clearstatcache();
|
||||
return true;
|
||||
}
|
||||
|
||||
$names = $this->splitPath($path);
|
||||
$dir = $this->getContentOfType($names['dirname'], vfsStreamContent::TYPE_DIR);
|
||||
if ($dir->isWritable(vfsStream::getCurrentUser(), vfsStream::getCurrentGroup()) === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
clearstatcache();
|
||||
return $dir->removeChild($child->getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* opens a directory
|
||||
*
|
||||
* @param string $path
|
||||
* @param int $options
|
||||
* @return bool
|
||||
*/
|
||||
public function dir_opendir($path, $options)
|
||||
{
|
||||
$path = $this->resolvePath(vfsStream::path($path));
|
||||
$this->dir = $this->getContentOfType($path, vfsStreamContent::TYPE_DIR);
|
||||
if (null === $this->dir || $this->dir->isReadable(vfsStream::getCurrentUser(), vfsStream::getCurrentGroup()) === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->dirIterator = $this->dir->getIterator();
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* reads directory contents
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function dir_readdir()
|
||||
{
|
||||
$dir = $this->dirIterator->current();
|
||||
if (null === $dir) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->dirIterator->next();
|
||||
return $dir->getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* reset directory iteration
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function dir_rewinddir()
|
||||
{
|
||||
return $this->dirIterator->rewind();
|
||||
}
|
||||
|
||||
/**
|
||||
* closes directory
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function dir_closedir()
|
||||
{
|
||||
$this->dirIterator = null;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns status of url
|
||||
*
|
||||
* @param string $path path of url to return status for
|
||||
* @param int $flags flags set by the stream API
|
||||
* @return array
|
||||
*/
|
||||
public function url_stat($path, $flags)
|
||||
{
|
||||
$content = $this->getContent($this->resolvePath(vfsStream::path($path)));
|
||||
if (null === $content) {
|
||||
if (($flags & STREAM_URL_STAT_QUIET) != STREAM_URL_STAT_QUIET) {
|
||||
trigger_error(' No such file or directory: ' . $path, E_USER_WARNING);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
$fileStat = array('dev' => 0,
|
||||
'ino' => 0,
|
||||
'mode' => $content->getType() | $content->getPermissions(),
|
||||
'nlink' => 0,
|
||||
'uid' => $content->getUser(),
|
||||
'gid' => $content->getGroup(),
|
||||
'rdev' => 0,
|
||||
'size' => $content->size(),
|
||||
'atime' => $content->fileatime(),
|
||||
'mtime' => $content->filemtime(),
|
||||
'ctime' => $content->filectime(),
|
||||
'blksize' => -1,
|
||||
'blocks' => -1
|
||||
);
|
||||
return array_merge(array_values($fileStat), $fileStat);
|
||||
}
|
||||
}
|
||||
?>
|
65
core/vendor/mikey179/vfsStream/src/main/php/org/bovigo/vfs/visitor/vfsStreamAbstractVisitor.php
vendored
Normal file
65
core/vendor/mikey179/vfsStream/src/main/php/org/bovigo/vfs/visitor/vfsStreamAbstractVisitor.php
vendored
Normal file
|
@ -0,0 +1,65 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of vfsStream.
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @package org\bovigo\vfs
|
||||
*/
|
||||
namespace org\bovigo\vfs\visitor;
|
||||
use org\bovigo\vfs\vfsStreamContent;
|
||||
use org\bovigo\vfs\vfsStreamBlock;
|
||||
|
||||
/**
|
||||
* Abstract base class providing an implementation for the visit() method.
|
||||
*
|
||||
* @since 0.10.0
|
||||
* @see https://github.com/mikey179/vfsStream/issues/10
|
||||
*/
|
||||
abstract class vfsStreamAbstractVisitor implements vfsStreamVisitor
|
||||
{
|
||||
/**
|
||||
* visit a content and process it
|
||||
*
|
||||
* @param vfsStreamContent $content
|
||||
* @return vfsStreamVisitor
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function visit(vfsStreamContent $content)
|
||||
{
|
||||
switch ($content->getType()) {
|
||||
case vfsStreamContent::TYPE_BLOCK:
|
||||
$this->visitBlockDevice($content);
|
||||
break;
|
||||
|
||||
case vfsStreamContent::TYPE_FILE:
|
||||
$this->visitFile($content);
|
||||
break;
|
||||
|
||||
case vfsStreamContent::TYPE_DIR:
|
||||
if (!$content->isDot()) {
|
||||
$this->visitDirectory($content);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new \InvalidArgumentException('Unknown content type ' . $content->getType() . ' for ' . $content->getName());
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* visit a block device and process it
|
||||
*
|
||||
* @param vfsStreamBlock $block
|
||||
* @return vfsStreamVisitor
|
||||
*/
|
||||
public function visitBlockDevice(vfsStreamBlock $block)
|
||||
{
|
||||
return $this->visitFile($block);
|
||||
}
|
||||
}
|
||||
?>
|
108
core/vendor/mikey179/vfsStream/src/main/php/org/bovigo/vfs/visitor/vfsStreamPrintVisitor.php
vendored
Normal file
108
core/vendor/mikey179/vfsStream/src/main/php/org/bovigo/vfs/visitor/vfsStreamPrintVisitor.php
vendored
Normal file
|
@ -0,0 +1,108 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of vfsStream.
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @package org\bovigo\vfs
|
||||
*/
|
||||
namespace org\bovigo\vfs\visitor;
|
||||
use org\bovigo\vfs\vfsStreamContent;
|
||||
use org\bovigo\vfs\vfsStreamDirectory;
|
||||
use org\bovigo\vfs\vfsStreamFile;
|
||||
use org\bovigo\vfs\vfsStreamBlock;
|
||||
|
||||
/**
|
||||
* Visitor which traverses a content structure recursively to print it to an output stream.
|
||||
*
|
||||
* @since 0.10.0
|
||||
* @see https://github.com/mikey179/vfsStream/issues/10
|
||||
*/
|
||||
class vfsStreamPrintVisitor extends vfsStreamAbstractVisitor
|
||||
{
|
||||
/**
|
||||
* target to write output to
|
||||
*
|
||||
* @type resource
|
||||
*/
|
||||
protected $out;
|
||||
/**
|
||||
* current depth in directory tree
|
||||
*
|
||||
* @type int
|
||||
*/
|
||||
protected $depth;
|
||||
|
||||
/**
|
||||
* constructor
|
||||
*
|
||||
* If no file pointer given it will fall back to STDOUT.
|
||||
*
|
||||
* @param resource $out optional
|
||||
* @throws \InvalidArgumentException
|
||||
* @api
|
||||
*/
|
||||
public function __construct($out = STDOUT)
|
||||
{
|
||||
if (is_resource($out) === false || get_resource_type($out) !== 'stream') {
|
||||
throw new \InvalidArgumentException('Given filepointer is not a resource of type stream');
|
||||
}
|
||||
|
||||
$this->out = $out;
|
||||
}
|
||||
|
||||
/**
|
||||
* visit a file and process it
|
||||
*
|
||||
* @param vfsStreamFile $file
|
||||
* @return vfsStreamPrintVisitor
|
||||
*/
|
||||
public function visitFile(vfsStreamFile $file)
|
||||
{
|
||||
$this->printContent($file->getName());
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* visit a block device and process it
|
||||
*
|
||||
* @param vfsStreamBlock $block
|
||||
* @return vfsStreamPrintVisitor
|
||||
*/
|
||||
public function visitBlockDevice(vfsStreamBlock $block)
|
||||
{
|
||||
$name = '[' . $block->getName() . ']';
|
||||
$this->printContent($name);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* visit a directory and process it
|
||||
*
|
||||
* @param vfsStreamDirectory $dir
|
||||
* @return vfsStreamPrintVisitor
|
||||
*/
|
||||
public function visitDirectory(vfsStreamDirectory $dir)
|
||||
{
|
||||
$this->printContent($dir->getName());
|
||||
$this->depth++;
|
||||
foreach ($dir as $child) {
|
||||
$this->visit($child);
|
||||
}
|
||||
|
||||
$this->depth--;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* helper method to print the content
|
||||
*
|
||||
* @param string $name
|
||||
*/
|
||||
protected function printContent($name)
|
||||
{
|
||||
fwrite($this->out, str_repeat(' ', $this->depth) . '- ' . $name . "\n");
|
||||
}
|
||||
}
|
||||
?>
|
112
core/vendor/mikey179/vfsStream/src/main/php/org/bovigo/vfs/visitor/vfsStreamStructureVisitor.php
vendored
Normal file
112
core/vendor/mikey179/vfsStream/src/main/php/org/bovigo/vfs/visitor/vfsStreamStructureVisitor.php
vendored
Normal file
|
@ -0,0 +1,112 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of vfsStream.
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @package org\bovigo\vfs
|
||||
*/
|
||||
namespace org\bovigo\vfs\visitor;
|
||||
use org\bovigo\vfs\vfsStreamDirectory;
|
||||
use org\bovigo\vfs\vfsStreamFile;
|
||||
use org\bovigo\vfs\vfsStreamBlock;
|
||||
|
||||
/**
|
||||
* Visitor which traverses a content structure recursively to create an array structure from it.
|
||||
*
|
||||
* @since 0.10.0
|
||||
* @see https://github.com/mikey179/vfsStream/issues/10
|
||||
*/
|
||||
class vfsStreamStructureVisitor extends vfsStreamAbstractVisitor
|
||||
{
|
||||
/**
|
||||
* collected structure
|
||||
*
|
||||
* @type array
|
||||
*/
|
||||
protected $structure = array();
|
||||
/**
|
||||
* poiting to currently iterated directory
|
||||
*
|
||||
* @type array
|
||||
*/
|
||||
protected $current;
|
||||
|
||||
/**
|
||||
* constructor
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->reset();
|
||||
}
|
||||
|
||||
/**
|
||||
* visit a file and process it
|
||||
*
|
||||
* @param vfsStreamFile $file
|
||||
* @return vfsStreamStructureVisitor
|
||||
*/
|
||||
public function visitFile(vfsStreamFile $file)
|
||||
{
|
||||
$this->current[$file->getName()] = $file->getContent();
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* visit a block device and process it
|
||||
*
|
||||
* @param vfsStreamBlock $block
|
||||
* @return vfsStreamStructureVisitor
|
||||
*/
|
||||
public function visitBlockDevice(vfsStreamBlock $block)
|
||||
{
|
||||
$this->current['[' . $block->getName() . ']'] = $block->getContent();
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* visit a directory and process it
|
||||
*
|
||||
* @param vfsStreamDirectory $dir
|
||||
* @return vfsStreamStructureVisitor
|
||||
*/
|
||||
public function visitDirectory(vfsStreamDirectory $dir)
|
||||
{
|
||||
$this->current[$dir->getName()] = array();
|
||||
$tmp =& $this->current;
|
||||
$this->current =& $tmp[$dir->getName()];
|
||||
foreach ($dir as $child) {
|
||||
$this->visit($child);
|
||||
}
|
||||
|
||||
$this->current =& $tmp;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns structure of visited contents
|
||||
*
|
||||
* @return array
|
||||
* @api
|
||||
*/
|
||||
public function getStructure()
|
||||
{
|
||||
return $this->structure;
|
||||
}
|
||||
|
||||
/**
|
||||
* resets structure so visitor could be reused
|
||||
*
|
||||
* @return vfsStreamStructureVisitor
|
||||
*/
|
||||
public function reset()
|
||||
{
|
||||
$this->structure = array();
|
||||
$this->current =& $this->structure;
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
?>
|
56
core/vendor/mikey179/vfsStream/src/main/php/org/bovigo/vfs/visitor/vfsStreamVisitor.php
vendored
Normal file
56
core/vendor/mikey179/vfsStream/src/main/php/org/bovigo/vfs/visitor/vfsStreamVisitor.php
vendored
Normal file
|
@ -0,0 +1,56 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of vfsStream.
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @package org\bovigo\vfs
|
||||
*/
|
||||
namespace org\bovigo\vfs\visitor;
|
||||
use org\bovigo\vfs\vfsStreamContent;
|
||||
use org\bovigo\vfs\vfsStreamDirectory;
|
||||
use org\bovigo\vfs\vfsStreamFile;
|
||||
use org\bovigo\vfs\vfsStreamBlock;
|
||||
|
||||
/**
|
||||
* Interface for a visitor to work on a vfsStream content structure.
|
||||
*
|
||||
* @since 0.10.0
|
||||
* @see https://github.com/mikey179/vfsStream/issues/10
|
||||
*/
|
||||
interface vfsStreamVisitor
|
||||
{
|
||||
/**
|
||||
* visit a content and process it
|
||||
*
|
||||
* @param vfsStreamContent $content
|
||||
* @return vfsStreamVisitor
|
||||
*/
|
||||
public function visit(vfsStreamContent $content);
|
||||
|
||||
/**
|
||||
* visit a file and process it
|
||||
*
|
||||
* @param vfsStreamFile $file
|
||||
* @return vfsStreamVisitor
|
||||
*/
|
||||
public function visitFile(vfsStreamFile $file);
|
||||
|
||||
/**
|
||||
* visit a directory and process it
|
||||
*
|
||||
* @param vfsStreamDirectory $dir
|
||||
* @return vfsStreamVisitor
|
||||
*/
|
||||
public function visitDirectory(vfsStreamDirectory $dir);
|
||||
|
||||
/**
|
||||
* visit a block device and process it
|
||||
*
|
||||
* @param vfsStreamBlock $block
|
||||
* @return vfsStreamVisitor
|
||||
*/
|
||||
public function visitBlockDevice(vfsStreamBlock $block);
|
||||
}
|
||||
?>
|
Reference in a new issue