summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2013-07-01 17:57:40 +0200
committerRobin Appelman <icewind@owncloud.com>2014-05-28 18:16:23 +0200
commit03ba497a8c1e149857d6c3a4d4cab49dea5903c1 (patch)
treeacc2cac257a525bb388d81842ba675358b00efc7 /lib
parent38c1da09768d034ee788f0c6a4284591e914fe4a (diff)
downloadnextcloud-server-03ba497a8c1e149857d6c3a4d4cab49dea5903c1.tar.gz
nextcloud-server-03ba497a8c1e149857d6c3a4d4cab49dea5903c1.zip
add recursive copy to local storage backend
Diffstat (limited to 'lib')
-rw-r--r--lib/private/files/storage/local.php26
1 files changed, 20 insertions, 6 deletions
diff --git a/lib/private/files/storage/local.php b/lib/private/files/storage/local.php
index ec28ebac6ee..dc6e7a12c65 100644
--- a/lib/private/files/storage/local.php
+++ b/lib/private/files/storage/local.php
@@ -179,20 +179,34 @@ if (\OC_Util::runningOnWindows()) {
if ($this->is_dir($path2)) {
$this->rmdir($path2);
+ } else if ($this->is_file($path2)) {
+ $this->unlink($path2);
}
return rename($this->datadir . $path1, $this->datadir . $path2);
}
public function copy($path1, $path2) {
- if ($this->is_dir($path2)) {
- if (!$this->file_exists($path2)) {
- $this->mkdir($path2);
+ if ($this->is_dir($path1)) {
+ if ($this->is_dir($path2)) {
+ $this->rmdir($path2);
+ } else if ($this->is_file($path2)) {
+ $this->unlink($path2);
+ }
+ $dir = $this->opendir($path1);
+ $this->mkdir($path2);
+ while ($file = readdir($dir)) {
+ if (($file != '.') && ($file != '..')) {
+ if (!$this->copy($path1 . '/' . $file, $path2 . '/' . $file)) {
+ return false;
+ }
+ }
}
- $source = substr($path1, strrpos($path1, '/') + 1);
- $path2 .= $source;
+ closedir($dir);
+ return true;
+ } else {
+ return copy($this->datadir . $path1, $this->datadir . $path2);
}
- return copy($this->datadir . $path1, $this->datadir . $path2);
}
public function fopen($path, $mode) {