diff options
author | Mario <mario@mariovavti.com> | 2019-12-04 10:25:11 +0000 |
---|---|---|
committer | Mario <mario@mariovavti.com> | 2019-12-04 10:25:11 +0000 |
commit | bde429cff649237984903a252ba1a718e6d74f53 (patch) | |
tree | b2b2570159cfb37689e6ce3b96c3b1b988d676cc /vendor/sabre/dav/lib/DAV/FS/Node.php | |
parent | cc9f41df5f83bcab435d6fb941b5a8f5b1457037 (diff) | |
parent | 4c8d33d1eb2a804aa70a7bc677d6c73d0d94816b (diff) | |
download | volse-hubzilla-bde429cff649237984903a252ba1a718e6d74f53.tar.gz volse-hubzilla-bde429cff649237984903a252ba1a718e6d74f53.tar.bz2 volse-hubzilla-bde429cff649237984903a252ba1a718e6d74f53.zip |
Merge branch '4.6RC'4.6
Diffstat (limited to 'vendor/sabre/dav/lib/DAV/FS/Node.php')
-rw-r--r-- | vendor/sabre/dav/lib/DAV/FS/Node.php | 72 |
1 files changed, 44 insertions, 28 deletions
diff --git a/vendor/sabre/dav/lib/DAV/FS/Node.php b/vendor/sabre/dav/lib/DAV/FS/Node.php index 424718f96..32aa74755 100644 --- a/vendor/sabre/dav/lib/DAV/FS/Node.php +++ b/vendor/sabre/dav/lib/DAV/FS/Node.php @@ -1,12 +1,15 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\FS; -use Sabre\DAV; -use Sabre\HTTP\URLUtil; +use Sabre\DAV\Exception\Forbidden; +use Sabre\DAV\INode; +use Sabre\Uri; /** - * Base node-class + * Base node-class. * * The node class implements the method used by both the File and the Directory classes * @@ -14,67 +17,80 @@ use Sabre\HTTP\URLUtil; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -abstract class Node implements DAV\INode { - +abstract class Node implements INode +{ /** - * The path to the current node + * The path to the current node. * * @var string */ protected $path; /** - * Sets up the node, expects a full path name + * The overridden name of the node. * - * @param string $path + * @var string */ - function __construct($path) { + protected $overrideName; + /** + * Sets up the node, expects a full path name. + * + * If $overrideName is set, this node shows up in the tree under a + * different name. In this case setName() will be disabled. + * + * @param string $path + * @param string $overrideName + */ + public function __construct($path, $overrideName = null) + { $this->path = $path; - + $this->overrideName = $overrideName; } - - /** - * Returns the name of the node + * Returns the name of the node. * * @return string */ - function getName() { + public function getName() + { + if ($this->overrideName) { + return $this->overrideName; + } - list(, $name) = URLUtil::splitPath($this->path); - return $name; + list(, $name) = Uri\split($this->path); + return $name; } /** - * Renames the node + * Renames the node. * * @param string $name The new name - * @return void */ - function setName($name) { + public function setName($name) + { + if ($this->overrideName) { + throw new Forbidden('This node cannot be renamed'); + } - list($parentPath, ) = URLUtil::splitPath($this->path); - list(, $newName) = URLUtil::splitPath($name); + list($parentPath) = Uri\split($this->path); + list(, $newName) = Uri\split($name); - $newPath = $parentPath . '/' . $newName; + $newPath = $parentPath.'/'.$newName; rename($this->path, $newPath); $this->path = $newPath; - } /** - * Returns the last modification time, as a unix timestamp + * Returns the last modification time, as a unix timestamp. * * @return int */ - function getLastModified() { - + public function getLastModified() + { return filemtime($this->path); - } - } |