aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/sabre/dav/lib/DAV/FS/Node.php
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2019-11-10 12:49:51 +0000
committerMario <mario@mariovavti.com>2019-11-10 14:10:03 +0100
commit580c3f4ffe9608d2beb56d418c68b3b112420e76 (patch)
tree82335d01179ac361d3f547a4b8e8c598d302e9f3 /vendor/sabre/dav/lib/DAV/FS/Node.php
parentd22766f458a8539a40a57f3946459a9be1f21cd6 (diff)
downloadvolse-hubzilla-580c3f4ffe9608d2beb56d418c68b3b112420e76.tar.gz
volse-hubzilla-580c3f4ffe9608d2beb56d418c68b3b112420e76.tar.bz2
volse-hubzilla-580c3f4ffe9608d2beb56d418c68b3b112420e76.zip
another bulk of composer updates
(cherry picked from commit 6685381fd8db507493c3d7c1793f8c05c681bbce)
Diffstat (limited to 'vendor/sabre/dav/lib/DAV/FS/Node.php')
-rw-r--r--vendor/sabre/dav/lib/DAV/FS/Node.php72
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);
-
}
-
}