improved copy operation for objecttree
This commit is contained in:
parent
1e0810e807
commit
93750d2658
1 changed files with 29 additions and 0 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue