You are here

protected function CertManager::tmpdir in Lockr 4.x

Creates a temporary directory for writing cert files.

Return value

string|bool Absolute path to the new temporary directory.

1 call to CertManager::tmpdir()
CertManager::writeCerts in src/CertManager.php
Writes the given key and cert files to a directory.

File

src/CertManager.php, line 217

Class

CertManager
Helper class for managing Lockr certificates.

Namespace

Drupal\lockr

Code

protected function tmpdir($dir) {
  $dir = rtrim($dir, '/');
  if (!is_dir($dir) || !is_writable($dir)) {
    return FALSE;
  }
  $prefix = "{$dir}/.lockr_tmp_";
  for ($i = 0; $i < 1000; $i++) {
    $path = $prefix . (string) mt_rand(100000, mt_getrandmax());
    if (@mkdir($path, 0750)) {
      return $path;
    }
  }
  return FALSE;
}