file_unmanaged_delete

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

Delete a file without calling any hooks or making any changes to the database.

This function should be used when the file to be deleted does not have an entry recorded in the files table.

see file_delete()

Übergabeparameter

$path A string containing a file path.

Rückgabewert

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

See also

file_unmanaged_delete_recursive()

Verwandte Themen

▾ 9 functions call file_unmanaged_delete()

FileUnmanagedDeleteTest::testDirectory in modules/simpletest/tests/file.test
Try deleting a directory.
FileUnmanagedDeleteTest::testMissing in modules/simpletest/tests/file.test
Try deleting a missing file.
FileUnmanagedDeleteTest::testNormal in modules/simpletest/tests/file.test
Delete a normal file.
file_delete in includes/file.inc
Delete a file and its database record.
file_unmanaged_delete_recursive in includes/file.inc
Recursively delete all files and directories in the specified filepath.
file_unmanaged_move in includes/file.inc
Move a file to a new location without calling any hooks or making any changes to the database.
locale_uninstall in modules/locale/locale.install
Implementation of hook_uninstall().
simpletest_uninstall in modules/simpletest/simpletest.install
Implementation of hook_uninstall().
_locale_rebuild_js in includes/locale.inc
(Re-)Creates the JavaScript translation file for a language.

Code

includes/file.inc, line 783

<?php
function file_unmanaged_delete($path) {
  if (is_dir($path)) {
    watchdog('file', '%path is a directory and cannot be removed using file_unmanaged_delete().', array('%path' => $path), WATCHDOG_ERROR);
    return FALSE;
  }
  if (is_file($path)) {
    return unlink($path);
  }
  // Return TRUE for non-existent file, but log that nothing was actually
  // deleted, as the current state is the indended result.
  if (!file_exists($path)) {
    watchdog('file', 'The file %path was not deleted, because it does not exist.', array('%path' => $path), WATCHDOG_NOTICE);
    return TRUE;
  }
  // We cannot handle anything other than files and directories. Log an error
  // for everything else (sockets, symbolic links, etc).
  watchdog('file', 'The file %path is not of a recognized type so it was not deleted.', array('%path' => $path), WATCHDOG_ERROR);
  return FALSE;
}
?>

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