protected function FileStorage::unlink

Deletes files and/or directories in the specified path.

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

Parameters

string $path: A string containing either a file or directory path.

Return value

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

4 calls to FileStorage::unlink()
FileStorage::delete in drupal/core/lib/Drupal/Component/PhpStorage/FileStorage.php
Implements Drupal\Component\PhpStorage\PhpStorageInterface::delete().
FileStorage::deleteAll in drupal/core/lib/Drupal/Component/PhpStorage/FileStorage.php
Implements Drupal\Component\PhpStorage\PhpStorageInterface::deleteAll().
MTimeProtectedFastFileStorage::cleanDirectory in drupal/core/lib/Drupal/Component/PhpStorage/MTimeProtectedFastFileStorage.php
Removes everything in a directory, leaving it empty.
MTimeProtectedFastFileStorage::save in drupal/core/lib/Drupal/Component/PhpStorage/MTimeProtectedFastFileStorage.php
Implements Drupal\Component\PhpStorage\PhpStorageInterface::save().

File

drupal/core/lib/Drupal/Component/PhpStorage/FileStorage.php, line 109
Definition of Drupal\Component\PhpStorage\FileStorage.

Class

FileStorage
Stores the code as regular PHP files.

Namespace

Drupal\Component\PhpStorage

Code

protected function unlink($path) {
  if (file_exists($path)) {

    // Ensure the file / folder is writable.
    chmod($path, 0700);
    if (is_dir($path)) {
      $dir = dir($path);
      while (($entry = $dir
        ->read()) !== FALSE) {
        if ($entry == '.' || $entry == '..') {
          continue;
        }
        $this
          ->unlink($path . '/' . $entry);
      }
      $dir
        ->close();
      return @rmdir($path);
    }
    return @unlink($path);
  }

  // If there's nothing to delete return TRUE anyway.
  return TRUE;
}