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

Breadcrumb

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

function Filesystem::emptyDirectory

Return value

void

File

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

Class

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

Namespace

Composer\Util

Code

public function emptyDirectory(string $dir, bool $ensureDirectoryExists = true) {
    if (is_link($dir) && file_exists($dir)) {
        $this->unlink($dir);
    }
    if ($ensureDirectoryExists) {
        $this->ensureDirectoryExists($dir);
    }
    if (is_dir($dir)) {
        $finder = Finder::create()->ignoreVCS(false)
            ->ignoreDotFiles(false)
            ->depth(0)
            ->in($dir);
        foreach ($finder as $path) {
            $this->remove((string) $path);
        }
    }
}

API Navigation

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