aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/sabre/dav/lib/DAV/FS
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/sabre/dav/lib/DAV/FS')
-rw-r--r--vendor/sabre/dav/lib/DAV/FS/Directory.php92
-rw-r--r--vendor/sabre/dav/lib/DAV/FS/File.php62
-rw-r--r--vendor/sabre/dav/lib/DAV/FS/Node.php72
3 files changed, 115 insertions, 111 deletions
diff --git a/vendor/sabre/dav/lib/DAV/FS/Directory.php b/vendor/sabre/dav/lib/DAV/FS/Directory.php
index 362f7a411..047692294 100644
--- a/vendor/sabre/dav/lib/DAV/FS/Directory.php
+++ b/vendor/sabre/dav/lib/DAV/FS/Directory.php
@@ -1,20 +1,22 @@
<?php
+declare(strict_types=1);
+
namespace Sabre\DAV\FS;
use Sabre\DAV;
/**
- * Directory class
+ * Directory class.
*
* @copyright Copyright (C) fruux GmbH (https://fruux.com/)
* @author Evert Pot (http://evertpot.com/)
* @license http://sabre.io/license/ Modified BSD License
*/
-class Directory extends Node implements DAV\ICollection, DAV\IQuota {
-
+class Directory extends Node implements DAV\ICollection, DAV\IQuota
+{
/**
- * Creates a new file in the directory
+ * Creates a new file in the directory.
*
* Data will either be supplied as a stream resource, or in certain cases
* as a string. Keep in mind that you may have to support either.
@@ -33,67 +35,63 @@ class Directory extends Node implements DAV\ICollection, DAV\IQuota {
* return the same contents of what was submitted here, you are strongly
* recommended to omit the ETag.
*
- * @param string $name Name of the file
+ * @param string $name Name of the file
* @param resource|string $data Initial payload
- * @return null|string
+ *
+ * @return string|null
*/
- function createFile($name, $data = null) {
-
- $newPath = $this->path . '/' . $name;
+ public function createFile($name, $data = null)
+ {
+ $newPath = $this->path.'/'.$name;
file_put_contents($newPath, $data);
clearstatcache(true, $newPath);
-
}
/**
- * Creates a new subdirectory
+ * Creates a new subdirectory.
*
* @param string $name
- * @return void
*/
- function createDirectory($name) {
-
- $newPath = $this->path . '/' . $name;
+ public function createDirectory($name)
+ {
+ $newPath = $this->path.'/'.$name;
mkdir($newPath);
clearstatcache(true, $newPath);
-
}
/**
- * Returns a specific child node, referenced by its name
+ * Returns a specific child node, referenced by its name.
*
* This method must throw DAV\Exception\NotFound if the node does not
* exist.
*
* @param string $name
+ *
* @throws DAV\Exception\NotFound
+ *
* @return DAV\INode
*/
- function getChild($name) {
-
- $path = $this->path . '/' . $name;
-
- if (!file_exists($path)) throw new DAV\Exception\NotFound('File with name ' . $path . ' could not be located');
+ public function getChild($name)
+ {
+ $path = $this->path.'/'.$name;
+ if (!file_exists($path)) {
+ throw new DAV\Exception\NotFound('File with name '.$path.' could not be located');
+ }
if (is_dir($path)) {
-
return new self($path);
-
} else {
-
return new File($path);
-
}
-
}
/**
- * Returns an array with all the child nodes
+ * Returns an array with all the child nodes.
*
* @return DAV\INode[]
*/
- function getChildren() {
-
+ public function getChildren()
+ {
$nodes = [];
$iterator = new \FilesystemIterator(
$this->path,
@@ -101,51 +99,49 @@ class Directory extends Node implements DAV\ICollection, DAV\IQuota {
| \FilesystemIterator::SKIP_DOTS
);
foreach ($iterator as $entry) {
-
$nodes[] = $this->getChild($entry->getFilename());
-
}
- return $nodes;
+ return $nodes;
}
/**
* Checks if a child exists.
*
* @param string $name
+ *
* @return bool
*/
- function childExists($name) {
+ public function childExists($name)
+ {
+ $path = $this->path.'/'.$name;
- $path = $this->path . '/' . $name;
return file_exists($path);
-
}
/**
- * Deletes all files in this directory, and then itself
- *
- * @return void
+ * Deletes all files in this directory, and then itself.
*/
- function delete() {
-
- foreach ($this->getChildren() as $child) $child->delete();
+ public function delete()
+ {
+ foreach ($this->getChildren() as $child) {
+ $child->delete();
+ }
rmdir($this->path);
-
}
/**
- * Returns available diskspace information
+ * Returns available diskspace information.
*
* @return array
*/
- function getQuotaInfo() {
+ public function getQuotaInfo()
+ {
$absolute = realpath($this->path);
+
return [
disk_total_space($absolute) - disk_free_space($absolute),
- disk_free_space($absolute)
+ disk_free_space($absolute),
];
-
}
-
}
diff --git a/vendor/sabre/dav/lib/DAV/FS/File.php b/vendor/sabre/dav/lib/DAV/FS/File.php
index 4fc5af057..b78a80138 100644
--- a/vendor/sabre/dav/lib/DAV/FS/File.php
+++ b/vendor/sabre/dav/lib/DAV/FS/File.php
@@ -1,66 +1,61 @@
<?php
+declare(strict_types=1);
+
namespace Sabre\DAV\FS;
use Sabre\DAV;
/**
- * File class
+ * File class.
*
* @copyright Copyright (C) fruux GmbH (https://fruux.com/)
* @author Evert Pot (http://evertpot.com/)
* @license http://sabre.io/license/ Modified BSD License
*/
-class File extends Node implements DAV\IFile {
-
+class File extends Node implements DAV\IFile
+{
/**
- * Updates the data
+ * Updates the data.
*
* @param resource $data
- * @return void
*/
- function put($data) {
-
+ public function put($data)
+ {
file_put_contents($this->path, $data);
clearstatcache(true, $this->path);
-
}
/**
- * Returns the data
+ * Returns the data.
*
* @return resource
*/
- function get() {
-
+ public function get()
+ {
return fopen($this->path, 'r');
-
}
/**
- * Delete the current file
- *
- * @return void
+ * Delete the current file.
*/
- function delete() {
-
+ public function delete()
+ {
unlink($this->path);
-
}
/**
- * Returns the size of the node, in bytes
+ * Returns the size of the node, in bytes.
*
* @return int
*/
- function getSize() {
-
+ public function getSize()
+ {
return filesize($this->path);
-
}
/**
- * Returns the ETag for a file
+ * Returns the ETag for a file.
*
* An ETag is a unique identifier representing the current version of the file. If the file changes, the ETag MUST change.
* The ETag is an arbitrary string, but MUST be surrounded by double-quotes.
@@ -69,27 +64,24 @@ class File extends Node implements DAV\IFile {
*
* @return mixed
*/
- function getETag() {
-
- return '"' . sha1(
- fileinode($this->path) .
- filesize($this->path) .
+ public function getETag()
+ {
+ return '"'.sha1(
+ fileinode($this->path).
+ filesize($this->path).
filemtime($this->path)
- ) . '"';
-
+ ).'"';
}
/**
- * Returns the mime-type for a file
+ * Returns the mime-type for a file.
*
* If null is returned, we'll assume application/octet-stream
*
* @return mixed
*/
- function getContentType() {
-
+ public function getContentType()
+ {
return null;
-
}
-
}
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);
-
}
-
}