Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Filesystem.php

function Filesystem::removeDirectory

Recursively remove a directory

Uses the process component if proc_open is enabled on the PHP installation.

Return value

bool

Throws

\RuntimeException

1 call to Filesystem::removeDirectory()
Filesystem::remove in vendor/composer/composer/src/Composer/Util/Filesystem.php

File

vendor/composer/composer/src/Composer/Util/Filesystem.php, line 104

Class

Filesystem
@author Jordi Boggiano <j.boggiano@seld.be> @author Johannes M. Schmitt <schmittjoh@gmail.com>

Namespace

Composer\Util

Code

public function removeDirectory(string $directory) {
    $edgeCaseResult = $this->removeEdgeCases($directory);
    if ($edgeCaseResult !== null) {
        return $edgeCaseResult;
    }
    if (Platform::isWindows()) {
        $cmd = [
            'rmdir',
            '/S',
            '/Q',
            Platform::realpath($directory),
        ];
    }
    else {
        $cmd = [
            'rm',
            '-rf',
            $directory,
        ];
    }
    $result = $this->getProcess()
        ->execute($cmd, $output) === 0;
    // clear stat cache because external processes aren't tracked by the php stat cache
    clearstatcache();
    if ($result && !is_dir($directory)) {
        return true;
    }
    return $this->removeDirectoryPhp($directory);
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal