file_unmanaged_delete($path)
drupal/includes/file.inc, line 738
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()
$path A string containing a file path.
TRUE for success or path does not exist, or FALSE in the event of an error.
| Name | Description |
|---|---|
| File interface | Common file handling functions. |
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;
}
// Catch all for everything else: sockets, symbolic links, etc.
return FALSE;
}