Composer::deleteRecursive

protected static Composer::deleteRecursive($path)

Helper method to remove directories and the files they contain.

Parameters

string $path: The directory or file to remove. It must exist.

Return value

bool TRUE on success or FALSE on failure.

File

core/lib/Drupal/Core/Composer/Composer.php, line 231

Class

Composer
Provides static functions for composer script events.

Namespace

Drupal\Core\Composer

Code

protected static function deleteRecursive($path) {
  if (is_file($path) || is_link($path)) {
    return unlink($path);
  }
  $success = TRUE;
  $dir = dir($path);
  while (($entry = $dir->read()) !== FALSE) {
    if ($entry == '.' || $entry == '..') {
      continue;
    }
    $entry_path = $path . '/' . $entry;
    $success = static::deleteRecursive($entry_path) && $success;
  }
  $dir->close();

  return rmdir($path) && $success;
}
doc_Drupal
2016-10-29 08:51:40
Comments
Leave a Comment

Please login to continue.