file_unmanaged_delete_recursive

  1. drupal
    1. drupal7
Versionen
drupal7 file_unmanaged_delete_recursive($path)

Recursively delete all files and directories in the specified filepath.

If the specified path is a directory then the function will call itself recursively to process the contents. Once the contents have been removed the directory will also be removed.

If the specified path is a file then it will be passed to file_unmanaged_delete().

Note that this only deletes visible files with write permission.

see file_unmanaged_delete()

Übergabeparameter

$path A string containing a file or directory path.

Rückgabewert

TRUE for success or path does not exist, or FALSE in the event of an error.

Verwandte Themen

▾ 7 functions call file_unmanaged_delete_recursive()

FileUnmanagedDeleteRecursiveTest::testDirectory in modules/simpletest/tests/file.test
Try deleting a directory with some files.
FileUnmanagedDeleteRecursiveTest::testEmptyDirectory in modules/simpletest/tests/file.test
Try deleting an empty directory.
FileUnmanagedDeleteRecursiveTest::testSingleFile in modules/simpletest/tests/file.test
Delete a normal file.
FileUnmanagedDeleteRecursiveTest::testSubDirectory in modules/simpletest/tests/file.test
Try deleting subdirectories with some files.
file_unmanaged_delete_recursive in includes/file.inc
Recursively delete all files and directories in the specified filepath.
simpletest_clean_temporary_directories in modules/simpletest/simpletest.module
Find all left over temporary directories and remove them.
tearDown in modules/simpletest/drupal_web_test_case.php
Delete created files and temporary files directory, delete the tables created by setUp(), and reset the database prefix.

Code

includes/file.inc, line 823

<?php
function file_unmanaged_delete_recursive($path) {
  if (is_dir($path)) {
    $dir = dir($path);
    while (($entry = $dir->read()) !== FALSE) {
      if ($entry == '.' || $entry == '..') {
        continue;
      }
      $entry_path = $path . '/' . $entry;
      file_unmanaged_delete_recursive($entry_path);
    }
    $dir->close();
    return rmdir($path);
  }
  return file_unmanaged_delete($path);
}
?>

Kommentare

Kommentar hinzufügen

Der Inhalt dieses Feldes wird nicht öffentlich zugänglich angezeigt.
  • Internet- und E-Mail-Adressen werden automatisch umgewandelt.
  • Zulässige HTML-Tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Zeilen und Absätze werden automatisch erzeugt.

Weitere Informationen über Formatierungsoptionen

Kommentar hinzufügen

Der Inhalt dieses Feldes wird nicht öffentlich zugänglich angezeigt.
  • Internet- und E-Mail-Adressen werden automatisch umgewandelt.
  • Zulässige HTML-Tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Zeilen und Absätze werden automatisch erzeugt.

Weitere Informationen über Formatierungsoptionen