Delete a directory.

@param string $dirname
@return bool True on success, false on failure.
191559
public static function deleteDir(string $dirname) : bool
     {
         if (!is_dir($dirname)) {
             return false;
         }

         // Delete dir
         if (is_dir($dirname)) {
             $ob = scandir($dirname);
             foreach ($ob as $o) {
                 if ($o != '.' && $o != '..') {
                     if (filetype($dirname.'/'.$o) == 'dir') {
                         Filesystem::deleteDir($dirname.'/'.$o);
                     } else {
                         unlink($dirname.'/'.$o);
                     }
                 }
             }
         }

         reset($ob);
         rmdir($dirname);

         return true;
     }
179590
public static function delete($path)
	{
		if (is_dir($path)) {
			Dir::delete($path);
		} elseif (is_file($path)) {
			File::delete($path);
		}

		return true;
	}
1272349
public function makeDirectory($dirname, $mode = 0777)
    {
        $directories = explode('/', $dirname);

        foreach ($directories as $directory) {
            if (false === $this->makeActualDirectory($directory, $mode)) {
                chdir($this->base_directory);
                return false;
            }
            chdir($directory);
            $this->current_working_dir = getcwd();
        }

        chdir($this->base_directory);

        return true;
    }
802889
public function dirDelete($dir)
    {
        $dir = $this->alias->resolve($dir);

        if (!is_dir($dir)) {
            return;
        }

        $this->_dirDelete($dir);
    }
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);
    }
232015
public static function delete($path)
    {
        if (is_dir($path)) {
            Folder::delete($path);
        } elseif (is_file($path)) {
            File::delete($path);
        }

        return true;
    }
203430
public function rmdirr($dirname)
    {
        // Sanity check
        if (!$this->file_exists($dirname)) {
            return false;
        }

        // Simple delete for a file
        if ($this->is_file($dirname) || $this->is_link($dirname)) {
            return $this->unlink($dirname);
        }

        // Loop through the folder
        $dir = $this->dir($dirname);
        while (false !== $entry = $dir->read()) {
            // Skip pointers
            if ($entry == '.' || $entry == '..') {
                continue;
            }
            // Recurse
            $this->rmdirr($dirname . DIRECTORY_SEPARATOR . $entry);
        }

        // Clean up
        $dir->close();
        return $this->rmdir($dirname);
    }
927335
public function deleteDir($dirname)
    {
        $item = $this->listDirContents($dirname);
        $enties = array_map(function($file) {
            return new \Qiniu_RS_EntryPath($this->bucket, $file['key']);
        }, $item);
        list($ret, $err) = Qiniu_RS_BatchDelete($this->getClient(), $enties);
        return $err === null;
    }
1152554
public function createDir(string $dirname, array $config = []): bool
    {
        $location = $this->applyBasePath($dirname);

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

        $umask = umask(0);
        $visibility = Arr::get($config, 'visibility', 'public');

        if (mkdir($location, $this->permissions['dir'][$visibility], true)) {
            umask($umask);

            return true;
        }

        return false;
    }
232743
static function deleteDirectory($dirPath)
    {
        $dirPath = realpath($dirPath);
        if (!is_dir($dirPath)) return false;
        if (!static::cleanDirectory($dirPath)) return false;
        return rmdir(realpath($dirPath));
    }
140559
public function deleteDir($dirname)
    {
        try {
            $prefix = $this->applyPathPrefix($dirname) . '/';
            $this->s3Client->deleteMatchingObjects($this->bucket, $prefix);
        } catch (DeleteMultipleObjectsException $exception) {
            return false;
        }

        return true;
    }
625494
public function delete()
    {
        // Deleting all children
        foreach ($this->getChildren() as $child) {
            $child->delete();
        }

        // Removing the directory itself
        rmdir($this->path);

        return true;
    }
795829
protected function removeRecursiveDirectory(string $dirPath): bool
    {
        $itemList = array_diff(scandir($dirPath), ['.', '..']);
        
        foreach ($itemList as $itemName) {
            $itemPath = $dirPath.'/'.$itemName;
            
            if (is_dir($itemPath)) {
                $this->removeRecursiveDirectory($itemPath);
            } else {
                unlink($itemPath);
            }
        }
        
        return rmdir($dirPath);
    }
121616
public static function deleteFolder($dir)
    {
        $dh = @opendir($dir);
        if (!$dh) {
            return false;
        }
        while (false !== ($file = readdir($dh))) {
            if (($file != '.') && ($file != '..')) {
                $full = $dir . '/' . $file;
                if (is_dir($full)) {
                    self::deleteFolder($full);
                } else {
                    unlink($full);
                }
            }
        }
        closedir($dh);
        rmdir($dir);
        return true;
    }
940836
public static function remove($dirname)
    {
        if (!is_dir($dirname)) {
            return false;
        }

        $dir = dir($dirname);

        while (false !== $entry = $dir->read()) {
            if ($entry == '.' || $entry == '..') {
                continue;
            }
            $item = $dirname . '/' . $entry;

            if (is_dir($item)) {
                static::remove($item);
            } else {
                unlink($item);
            }
        }

        return rmdir($dirname);
    }
798940
public function delete( $drilldown = false ) : bool
    {
        if ( is_file( $this->path ) ){
            return @unlink( $this->path );
        }
        if ( $drilldown ){
            return self::removeDirectoryRecursive( $this->path );
        }
        return @rmdir( $this->path );
    }
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;
	}