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

Breadcrumb

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

function 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 347

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

API Navigation

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