elFinderVolumeFTP::deleteDir PHP Method

deleteDir() private method

Delete local directory recursively.
private deleteDir ( $dirPath ) : boolean
$dirPath string to directory to be erased.
return boolean true on success and false on failure.
    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;
    }