aboutsummaryrefslogtreecommitdiffstats
path: root/lib/connector/sabre
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2013-06-30 19:41:38 +0200
committerRobin Appelman <icewind@owncloud.com>2013-06-30 19:41:38 +0200
commit93750d2658d52df4475fefde79150a68a8012878 (patch)
tree8ed2d21a36eb1b63452529bc22752c9524c1ce5d /lib/connector/sabre
parent1e0810e80706211e0c7aa736172dc6fd1c34bde7 (diff)
downloadnextcloud-server-93750d2658d52df4475fefde79150a68a8012878.tar.gz
nextcloud-server-93750d2658d52df4475fefde79150a68a8012878.zip
improved copy operation for objecttree
Diffstat (limited to 'lib/connector/sabre')
-rw-r--r--lib/connector/sabre/objecttree.php29
1 files changed, 29 insertions, 0 deletions
diff --git a/lib/connector/sabre/objecttree.php b/lib/connector/sabre/objecttree.php
index f51b991d12a..dbc8c452d1b 100644
--- a/lib/connector/sabre/objecttree.php
+++ b/lib/connector/sabre/objecttree.php
@@ -70,4 +70,33 @@ class ObjectTree extends \Sabre_DAV_ObjectTree {
$this->markDirty($destinationDir);
}
+
+ /**
+ * Copies a file or directory.
+ *
+ * This method must work recursively and delete the destination
+ * if it exists
+ *
+ * @param string $source
+ * @param string $destination
+ * @return void
+ */
+ public function copy($source, $destination) {
+
+ if (Filesystem::is_file($source)) {
+ Filesystem::copy($source, $destination);
+ } else {
+ Filesystem::mkdir($destination);
+ $dh = Filesystem::opendir($source);
+ while ($subnode = readdir($dh)) {
+
+ if ($subnode == '.' || $subnode == '..') continue;
+ $this->copy($source . '/' . $subnode, $destination . '/' . $subnode);
+
+ }
+ }
+
+ list($destinationDir,) = \Sabre_DAV_URLUtil::splitPath($destination);
+ $this->markDirty($destinationDir);
+ }
}