function MTimeProtectedFastFileStorage::tempnam

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Component/PhpStorage/MTimeProtectedFastFileStorage.php \Drupal\Component\PhpStorage\MTimeProtectedFastFileStorage::tempnam()
  2. 8.9.x core/lib/Drupal/Component/PhpStorage/MTimeProtectedFastFileStorage.php \Drupal\Component\PhpStorage\MTimeProtectedFastFileStorage::tempnam()
  3. 10 core/lib/Drupal/Component/PhpStorage/MTimeProtectedFastFileStorage.php \Drupal\Component\PhpStorage\MTimeProtectedFastFileStorage::tempnam()

A brute force tempnam implementation supporting streams.

Parameters

$directory: The directory where the temporary filename will be created.

$prefix: The prefix of the generated temporary filename.

Return value

string Returns the new temporary filename (with path), or FALSE on failure.

1 call to MTimeProtectedFastFileStorage::tempnam()
MTimeProtectedFastFileStorage::save in core/lib/Drupal/Component/PhpStorage/MTimeProtectedFastFileStorage.php
Saves PHP code to storage.

File

core/lib/Drupal/Component/PhpStorage/MTimeProtectedFastFileStorage.php, line 228

Class

MTimeProtectedFastFileStorage
Stores PHP code in files with securely hashed names.

Namespace

Drupal\Component\PhpStorage

Code

protected function tempnam($directory, $prefix) {
    do {
        $path = $directory . '/' . $prefix . Crypt::randomBytesBase64(20);
    } while (file_exists($path));
    return $path;
}

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