FileStorage::unlink

protected FileStorage::unlink($path)

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

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

File

core/lib/Drupal/Component/PhpStorage/FileStorage.php, line 225

Class

FileStorage
Stores the code as regular PHP files.

Namespace

Drupal\Component\PhpStorage

Code

protected function unlink($path) {
  if (file_exists($path)) {
    if (is_dir($path)) {
      // Ensure the folder is writable.
      @chmod($path, 0777);
      foreach (new \DirectoryIterator($path) as $fileinfo) {
        if (!$fileinfo->isDot()) {
          $this->unlink($fileinfo->getPathName());
        }
      }
      return @rmdir($path);
    }
    // Windows needs the file to be writable.
    @chmod($path, 0700);
    return @unlink($path);
  }
  // If there's nothing to delete return TRUE anyway.
  return TRUE;
}
doc_Drupal
2016-10-29 09:13:43
Comments
Leave a Comment

Please login to continue.