drupal_unlink

  1. drupal
    1. 8
    2. 7
Versions
7 – 8 drupal_unlink($uri, $context = NULL)

Deletes a file.

PHP's unlink() is broken on Windows, as it can fail to remove a file when it has a read-only flag set.

Parameters

$uri A URI or pathname.

$context Refer to http://php.net/manual/en/ref.stream.php

Return value

Boolean TRUE on success, or FALSE on failure.

See also

unlink()

Related topics

▾ 17 functions call drupal_unlink()

Archive_Tar::_cleanFile in modules/system/system.tar.inc
Archive_Tar::_close in modules/system/system.tar.inc
Archive_Tar::_extractList in modules/system/system.tar.inc
Archive_Tar::_openAppend in modules/system/system.tar.inc
Archive_Tar::__destruct in modules/system/system.tar.inc
color_scheme_form_submit in modules/color/color.module
Submit handler for color change form.
DrupalLocalStreamWrapper::unlink in includes/stream_wrappers.inc
Support for unlink().
FileDirectoryTest::testFileCheckDirectoryHandling in modules/simpletest/tests/file.test
Test directory handling functions.
FileTransferLocal::removeDirectoryJailed in includes/filetransfer/local.inc
Removes a directory.
FileTransferLocal::removeFileJailed in includes/filetransfer/local.inc
Removes a file.
FileValidatorTest::testFileValidateImageResolution in modules/simpletest/tests/file.test
This ensures the resolution of a specific file is within bounds. The image will be resized if it's too large.
file_unmanaged_delete in includes/file.inc
Delete a file without calling any hooks or making any changes to the database.
install_check_requirements in includes/install.core.inc
Checks installation requirements and reports any errors.
LocaleExportFunctionalTest::testExportTranslation in modules/locale/locale.test
Test exportation of translations.
LocaleImportFunctionalTest::importPoFile in modules/locale/locale.test
Helper function: import a standalone .po file in a given language.
system_update_7046 in modules/system/system.install
Switch from the Minnelli theme if it is the default or admin theme.
update_manager_local_transfers_allowed in modules/update/update.manager.inc
Determines if file transfers will be performed locally.

Code

includes/file.inc, line 2181

<?php
function drupal_unlink($uri, $context = NULL) {
  $scheme = file_uri_scheme($uri);
  if ((!$scheme || !file_stream_wrapper_valid_scheme($scheme)) && (substr(PHP_OS, 0, 3) == 'WIN')) {
    chmod($uri, 0600);
  }
  if ($context) {
    return unlink($uri, $context);
  }
  else {
    return unlink($uri);
  }
}
?>