Delete a directory.

@param string $dirname

@throws RootViolationException Thrown if $dirname is empty.

@return bool True on success, false on failure.
192414
public function deleteDir($dirname)
    {
        $dirname = Util::normalizePath($dirname);

        if ($dirname === '') {
            throw new RootViolationException('Root directories can not be deleted.');
        }

        return (bool) $this->adapter->deleteDir($dirname);
    }
5072
private function deleteDir($dirPath)
	{
		if (!is_dir($dirPath)) {
			$success = unlink($dirPath);
		} else {
			$success = true;
			foreach (array_reverse(elFinderVolumeFTP::listFilesInDirectory($dirPath, false)) as $path) {
				$path = $dirPath . DIRECTORY_SEPARATOR . $path;
				if(is_link($path)) {
					unlink($path);
				} else if (is_dir($path)) {
					$success = rmdir($path);
				} else {
					$success = unlink($path);
				}
				if (!$success) {
					break;
				}
			}
			if($success) {
				$success = rmdir($dirPath);
			}
		}
		if(!$success) {
			$this->setError(elFinder::ERROR_RM, $dirPath);
			return false;
		}
		return $success;
	}
876085
private function _delete($filename, $directory = null)
    {
        $cache_path = $this->config->get('cache_path');

        if (is_null($directory)) {
            $path = $cache_path.$this->config->get('object_dir').$filename.'.cache';
        } else {
            $path = $cache_path.$directory.$filename.'.cache';
        }

        // nope. not here.
        if ( ! file_exists($path)) return true;
        return (bool) unlink($path);
    }
981460
public function deleteDir($dirname)
    {
        return (bool)$this->normalizeResponse(
            Cosapi::delFolder($this->getBucket(), $dirname)
        );
    }
631990
public function deleteDir($dirName)
    {
        $location = $this->applyPathPrefix($dirName);
        $lists = $this->listContents($location, true);
        if (!$lists) {
            return false;
        }
        $objectList = [];
        foreach ($lists as $value) {
            $objectList[] = $value['path'];
        }
        $this->ossClient->deleteObjects($this->bucket, $objectList);
        return true;
    }
962129
public function deleteFileByName($filename)
    {
        $destinationPath = $this->getDestinationPath();
        $destination = $destinationPath . '/' . $filename;

        if (file_exists($destination)) {
            $files = $this->getFiles();
            foreach ($files as $key => $file) {
                if ($file->file == $filename) {
                    unlink($destination);
                    unset($files[$key]);
                }
            }

            $files = array_values($files);
            $this->repository->files = $files;
            $this->save();
        }
    }
1231018
public function deleteDir(string $dirname): bool
    {
        $location = $this->applyBasePath($dirname);

        if (! is_dir($location)) {
            throw new DirectoryNotExistsException($dirname);
        }

        $contents = new RecursiveIteratorIterator(
            new RecursiveDirectoryIterator($location, FilesystemIterator::SKIP_DOTS),
            RecursiveIteratorIterator::CHILD_FIRST
        );

        foreach ($contents as $file) {
            if ($file->isReadable()) {
                switch ($file->getType()) {
                    case 'dir':
                        rmdir($file->getRealPath());
                        break;
                    case 'link':
                        unlink($file->getPathname());
                        break;
                    default:
                        unlink($file->getRealPath());
                        break;
                }
            }
        }

        unset($contents);

        return rmdir($location);
    }
181809
protected function _isMaildir($dirname)
    {
        if (file_exists($dirname . '/new') && !is_dir($dirname . '/new')) {
            return false;
        }
        if (file_exists($dirname . '/tmp') && !is_dir($dirname . '/tmp')) {
            return false;
        }
        return is_dir($dirname . '/cur');
    }
1160300
private function setConfigDirectory(string $dirName): void
    {
        $dirName = realpath($this->getDirectory(Config::DIR_ROOT) . $dirName);

        if (is_dir($dirName)) {
            $this->configDirectory = $dirName;
        } else {
            if ($dirName !== false) {
                throw new \InvalidArgumentException(sprintf('Directory "%s" does not exists', $dirName));
            } else {
                throw new \InvalidArgumentException(sprintf('Config directory does not exists', $dirName));
            }
        }
    }
954551
public static function isEmptyDir($dirname)
    {
      $files = scandir($dirname);
      if ( $files && count($files) > 2)
      {
        return false;
      }
      return true;
    }
288294
public function isDirectory($dirname)
    {
        $listing = $this->listDirectoryContents();

        $dirname_info = array_filter($listing, function ($item) use ($dirname) {
            return $item['type'] === 'directory' && $item['name'] === $dirname;
        });

        return count($dirname_info) !== 0;
    }
93715
public function remove($fileName): bool
    {
        return unlink($this->fileInfo->getAbsoluteFilePath() . MDir::getSeparator() . $fileName);
    }
1364415
public function dirIsEmpty($dirname)
    {
        if (!is_dir($dirname)) {
            return false;
        }
        foreach (scandir($dirname) as $file) {
            if (!in_array($file, array('.','..','.svn','.git'))) {
                return false;
            }
        }
        return true;
    }
925864
static public function emptyDir($dirpath)
    {
        foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dirpath, FilesystemIterator::SKIP_DOTS), RecursiveIteratorIterator::CHILD_FIRST) as $path) {
            $path->isFile() ? unlink($path->getPathname()) : rmdir($path->getPathname());
        }
    }
866507
public function handle($dirname, $options)
    {
        $dirname = Util::normalizePath($dirname);

        if ($dirname === '') {
            throw new RootViolationException('Root directories can not be deleted.');
        }

        $adapter = $this->filesystem->getAdapter();

        if ($options & STREAM_MKDIR_RECURSIVE) {
            // I don't know how this gets triggered.
            return (bool) $adapter->deleteDir($dirname);
        }

        $contents = $this->filesystem->listContents($dirname);

        if ( ! empty($contents)) {
            throw new DirectoryNotEmptyException();
        }

        return (bool) $adapter->deleteDir($dirname);
    }
802241
public function removeEmptyDirectory($directoryPath)
    {
        if (is_dir($directoryPath) && $this->isDirEmpty($directoryPath)) {
            if (!$this->removeDirectory($directoryPath)) {
                // @codeCoverageIgnoreStart
                throw new \RuntimeException('Unable to remove the directory : ' . $directoryPath);
                // @codeCoverageIgnoreEnd
            }

            return true;
        }

        return false;
    }
481989
public function deleteDir($dirname)
    {
        $dirname = rtrim($dirname, '/').'/';

        if (false === $this->has($dirname)) {
            return false;
        }

        $dirname = $this->applyPathPrefix($dirname);

        $this->bucket->object($dirname)->delete();

        return !$this->bucket->object($dirname)->exists();
    }