function FileSystem::tempnam

Same name in other branches
  1. 9 core/lib/Drupal/Core/File/FileSystem.php \Drupal\Core\File\FileSystem::tempnam()
  2. 8.9.x core/lib/Drupal/Core/File/FileSystem.php \Drupal\Core\File\FileSystem::tempnam()
  3. 10 core/lib/Drupal/Core/File/FileSystem.php \Drupal\Core\File\FileSystem::tempnam()

Overrides FileSystemInterface::tempnam

1 call to FileSystem::tempnam()
FileSystem::saveData in core/lib/Drupal/Core/File/FileSystem.php

File

core/lib/Drupal/Core/File/FileSystem.php, line 268

Class

FileSystem
Provides helpers to operate on files and stream wrappers.

Namespace

Drupal\Core\File

Code

public function tempnam($directory, $prefix) {
    $scheme = StreamWrapperManager::getScheme($directory);
    if ($this->streamWrapperManager
        ->isValidScheme($scheme)) {
        $wrapper = $this->streamWrapperManager
            ->getViaScheme($scheme);
        if ($filename = tempnam($wrapper->getDirectoryPath(), $prefix)) {
            return $scheme . '://' . static::basename($filename);
        }
        else {
            return FALSE;
        }
    }
    else {
        // Handle as a normal tempnam() call.
        return tempnam($directory, $prefix);
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.