You are here

public function DrupalTempFileAdapter::createTempFile in Backup and Migrate 5.0.x

Get a temporary file that can be written to.

Parameters

string $ext: The file extension to add to the temp file.

Return value

string The path to the file.

Overrides TempFileAdapter::createTempFile

File

src/Drupal/File/DrupalTempFileAdapter.php, line 43

Class

DrupalTempFileAdapter
@package Drupal\backup_migrate\Drupal\File

Namespace

Drupal\backup_migrate\Drupal\File

Code

public function createTempFile($ext = '') {

  // Add a dot to the file extension.
  $ext = $ext ? '.' . $ext : '';
  $file = $this->filesystem
    ->tempnam($this->dir, $this->prefix);
  if (!$file) {
    throw new \Exception('Could not create a temporary file to write to.');
  }
  $this->tempfiles[] = $file;
  return $file;
}