make rmdir recursive for mappellocal storage backend

This commit is contained in:
Robin Appelman 2013-06-30 17:44:49 +02:00
parent 63c898c064
commit d051d6f925
1 changed files with 23 additions and 3 deletions

View File

@ -34,10 +34,30 @@ class MappedLocal extends \OC\Files\Storage\Common{
return @mkdir($this->buildPath($path));
}
public function rmdir($path) {
if ($result = @rmdir($this->buildPath($path))) {
$this->cleanMapper($path);
try {
$it = new \RecursiveIteratorIterator(
new \RecursiveDirectoryIterator($this->buildPath($path)),
\RecursiveIteratorIterator::CHILD_FIRST
);
foreach ($it as $file) {
/**
* @var \SplFileInfo $file
*/
if (in_array($file->getBasename(), array('.', '..'))) {
continue;
} elseif ($file->isDir()) {
rmdir($file->getPathname());
} elseif ($file->isFile() || $file->isLink()) {
unlink($file->getPathname());
}
}
if ($result = @rmdir($this->buildPath($path))) {
$this->cleanMapper($path);
}
return $result;
} catch (\UnexpectedValueException $e) {
return false;
}
return $result;
}
public function opendir($path) {
$files = array('.', '..');