Deletes a directory and its contents from disk.

@param  string $path Path to directory
@return bool
499874
public function removeDirectory(string $path): bool
	{
		foreach(new FilesystemIterator($path) as $item)
		{
			if($item->isDir())
			{
				$this->removeDirectory($item->getPathname());
			}
			else
			{
				unlink($item->getPathname());
			}
		}

		return rmdir($path);
	}
142260
private static function rmdir($path) {
        foreach (glob($path . '/*') as $file) {
            if (is_dir($file)) {
                self::rmdir($file);
            } else {
                unlink($file);
            }
        }

        // Remove the remaining directory
        rmdir($path);
    }
168766
public function delete($path = null)
    {
        if (!$path) {
            $path = $this->pwd();
        }
        if (!$path) {
            return false;
        }
        $path = Folder::slashTerm($path);
        if (is_dir($path)) {
            try {
                $directory = new RecursiveDirectoryIterator($path, RecursiveDirectoryIterator::CURRENT_AS_SELF);
                $iterator = new RecursiveIteratorIterator($directory, RecursiveIteratorIterator::CHILD_FIRST);
            } catch (Exception $e) {
                return false;
            }

            foreach ($iterator as $item) {
                $filePath = $item->getPathname();
                if ($item->isFile() || $item->isLink()) {
                    //@codingStandardsIgnoreStart
                    if (@unlink($filePath)) {
                        //@codingStandardsIgnoreEnd
                        $this->_messages[] = sprintf('%s removed', $filePath);
                    } else {
                        $this->_errors[] = sprintf('%s NOT removed', $filePath);
                    }
                } elseif ($item->isDir() && !$item->isDot()) {
                    //@codingStandardsIgnoreStart
                    if (@rmdir($filePath)) {
                        //@codingStandardsIgnoreEnd
                        $this->_messages[] = sprintf('%s removed', $filePath);
                    } else {
                        $this->_errors[] = sprintf('%s NOT removed', $filePath);

                        return false;
                    }
                }
            }

            $path = rtrim($path, DIRECTORY_SEPARATOR);
            //@codingStandardsIgnoreStart
            if (@rmdir($path)) {
                //@codingStandardsIgnoreEnd
                $this->_messages[] = sprintf('%s removed', $path);
            } else {
                $this->_errors[] = sprintf('%s NOT removed', $path);

                return false;
            }
        }

        return true;
    }
948482
public static function delete($path)
    {
        if (!is_readable($path)) {
            return false;
        }

        if (!is_dir($path)) {
            unlink($path);
            return true;
        }

        foreach (scandir($path) as $file) {
            if ($file === '.' || $file === '..') {
                continue;
            }
            $file = $path . '/' . $file;
            if (is_dir($file)) {
                self::delete($file);
            } else {
                unlink($file);
            }
        }

        rmdir($path);

        return true;
    }
1303796
public function delete($path)
    {
        $result = $this->client->deleteObject([
            'Bucket' => $this->getBucket(),
            'Key'    => $path,
        ]);

        return (bool) $result;
    }
1241473
protected function _unlink($path) {
		return $this->query(sprintf('DELETE FROM %s WHERE id=%d AND mime!="directory" LIMIT 1', $this->tbf, $path)) && $this->db->affected_rows;
	}
711059
public function deleteRecursive($path)
	{
		if (!$this->tryDelete($path)) {
			foreach ((array) $this->nlist($path) as $file) {
				if ($file !== '.' && $file !== '..') {
					$this->deleteRecursive(strpos($file, '/') === FALSE ? "$path/$file" : $file);
				}
			}
			$this->rmdir($path);
		}
	}
828011
public static function RemoveFolder($Path) {
      if (!file_exists($Path))
         return;

      if (is_file($Path)) {
         unlink($Path);
         return;
      }

      $Path = rtrim($Path, '/').'/';

      // Get all of the files in the directory.
      if ($dh = opendir($Path)) {
         while (($File = readdir($dh)) !== false) {
            if (trim($File, '.') == '')
               continue;

            $SubPath = $Path.$File;

            if (is_dir($SubPath))
               self::RemoveFolder($SubPath);
            else
               unlink($SubPath);
         }
         closedir($dh);
      }
      rmdir($Path);
   }
278829
public function deleteDirectoryContents($path)
    {
        $dir = new \RecursiveDirectoryIterator($path);
        $iterator = new \RecursiveIteratorIterator($dir, \RecursiveIteratorIterator::CHILD_FIRST);

        /** @var \SplFileInfo $object */
        foreach ($iterator as $object) {
            if (!in_array($object->getBasename(), ['.', '..'])) {
                if ($object->isLink() || $object->isFile()) {
                    unlink($object->getPathname());
                } else if ($object->isDir()) {
                    rmdir($object->getPathname());
                }
            }
        }
    }
1155120
public function delete($path)
    {
        $result = Uploader::destroy($path, ['invalidate' => true]);

        return is_array($result) ? $result['result'] == 'ok' : false;
    }
828162
public function delete($path)
    {
        if (false === $json = $this->runRequest($path, 'DELETE')) {
            return false;
        }

        return $this->decode($json);
    }
1287190
public function remove($path)
    {
        $contents = $this->Acos->node($path);
        if (!$contents) {
            return false;
        }

        $content = $contents->first();
        $this->Acos->removeFromTree($content);
        $this->Acos->delete($content);

        return true;
    }
1264246
public static function delete($path)
    {
        @set_time_limit((int) ini_get('max_execution_time'));

        // Sanity check
        if (!rtrim($path, '/\\')) {
            // Bad programmer! Bad Bad programmer!
            throw new FilesystemException(__METHOD__ . ': You can not delete a base directory.');
        }

        // Check to make sure the path valid and clean
        $path = Path::clean($path);

        // Is this really a folder?
        if (!is_dir($path)) {
            throw new \UnexpectedValueException(sprintf('%1$s: Path is not a folder. Path: %2$s', __METHOD__, $path));
        }

        // Remove all the files in folder if they exist; disable all filtering
        $files = static::files($path);

        if (!empty($files)) {
            File::delete($files);
        }

        // Remove sub-folders of folder; disable all filtering
        $folders = static::items($path);

        foreach ($folders as $folder) {
            if (is_link($folder)) {
                // Don't descend into linked directories, just delete the link.
                File::delete($folder);
            } elseif (is_dir($folder)) {
                static::delete($folder);
            }
        }

        // In case of restricted permissions we zap it one way or the other
        // as long as the owner is either the webserver or the ftp.
        if (@rmdir($path)) {
            return true;
        } else {
            $error = error_get_last();
            throw new FilesystemException($error['message'], $error['type']);
        }
    }
409264
public function delete($path)
    {
        $location = $this->applyPathPrefix($path);
        $this->ossClient->deleteObject($this->bucket, $location);
        return true;
    }
1097420
public static function removeDirectory($path) {
        if (is_dir($path))
            $dir = opendir($path);
        if (!$dir)
            return false;
        while ($file = readdir($dir))
            if (!self::isDot($file)) {
	            if (!is_dir("$path/$file"))
                    unlink("$path/$file");
	            else
                    self::removeDirectory("$path/$file");
            }
        closedir($dir);
        rmdir($path);
        return true;
    }
448801
public static function remove($path)
    {
        $removed = 0;

        if (file_exists($path)) {
            if (is_dir($path)) {
                if (false === ($handle = @opendir($path))) {
                    throw PathException::createUsingLastError();
                }

                while (false !== ($item = readdir($handle))) {
                    if (('.' === $item) || ('..' === $item)) {
                        continue;
                    }

                    $removed += self::remove($path . DIRECTORY_SEPARATOR . $item);
                }

                closedir($handle);

                if (!@rmdir($path)) {
                    throw PathException::createUsingLastError();
                }
            } elseif (!@unlink($path)) {
                throw PathException::createUsingLastError();
            }

            $removed++;
        }

        return $removed;
    }
730907
protected function deleteContents($path)
    {
        $contents = $this->listContents($path, true);

        foreach (array_reverse($contents) as $object) {
            $location = $this->applyPathPrefix($object['path']);

            if ($object['type'] === 'dir') {
                $this->share->rmdir($location);
            } else {
                $this->share->del($location);
            }
        }
    }