protected function MTimeProtectedFastFileStorage::tempnam

protected MTimeProtectedFastFileStorage::tempnam($directory, $prefix)

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.

File

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

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 . substr(str_shuffle(hash('sha256', microtime())), 0, 10);
  } while (file_exists($path));
  return $path;
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Component!PhpStorage!MTimeProtectedFastFileStorage.php/function/MTimeProtectedFastFileStorage::tempnam/8.1.x