You are here

public function FileSystemInterface::deleteRecursive in Drupal 10

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/File/FileSystemInterface.php \Drupal\Core\File\FileSystemInterface::deleteRecursive()
  2. 9 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.

File

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

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);