public function FileSystem::tempnam in Drupal 10
Same name and namespace in other branches
- 8 core/lib/Drupal/Core/File/FileSystem.php \Drupal\Core\File\FileSystem::tempnam()
- 9 core/lib/Drupal/Core/File/FileSystem.php \Drupal\Core\File\FileSystem::tempnam()
File
- core/
lib/ Drupal/ Core/ File/ FileSystem.php, line 275
Class
- FileSystem
- Provides helpers to operate on files and stream wrappers.
Namespace
Drupal\Core\FileCode
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);
}
}