function FileSystemInterface::deleteRecursive

Same name in other branches
  1. 8.9.x core/lib/Drupal/Core/File/FileSystemInterface.php \Drupal\Core\File\FileSystemInterface::deleteRecursive()
  2. 10 core/lib/Drupal/Core/File/FileSystemInterface.php \Drupal\Core\File\FileSystemInterface::deleteRecursive()
  3. 11.x core/lib/Drupal/Core/File/FileSystemInterface.php \Drupal\Core\File\FileSystemInterface::deleteRecursive()

Deletes all files and directories in the specified filepath recursively.

If the specified path is a directory then the function is called recursively to process the contents. Once the contents have been removed the directory is also removed.

If the specified path is a file then it will be processed with delete() method.

Note that this only deletes visible files with write permission.

Parameters

string $path: A string containing either an URI or a file or directory path.

callable|null $callback: Callback function to run on each file prior to deleting it and on each directory prior to traversing it. For example, can be used to modify permissions.

Throws

\Drupal\Core\File\Exception\FileException Implementation may throw FileException or its subtype on failure.

1 method overrides FileSystemInterface::deleteRecursive()
FileSystem::deleteRecursive in core/lib/Drupal/Core/File/FileSystem.php
Deletes all files and directories in the specified filepath recursively.

File

core/lib/Drupal/Core/File/FileSystemInterface.php, line 322

Class

FileSystemInterface
Provides an interface for helpers that operate on files and stream wrappers.

Namespace

Drupal\Core\File

Code

public function deleteRecursive($path, callable $callback = NULL);

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.