You are here

public function DrupalTempFileAdapter::createTempFile in Backup and Migrate 8.4

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/File/DrupalTempFileAdapter.php, line 43

Class

DrupalTempFileAdapter
Class DrupalTempFileAdapter.

Namespace

BackupMigrate\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;
}