public function TempFileAdapter::deleteTempFile in Backup and Migrate 5.0.x
Delete a temporary file.
Parameters
string $filename: The path to the file.
Overrides TempFileAdapterInterface::deleteTempFile
1 call to TempFileAdapter::deleteTempFile()
- TempFileAdapter::deleteAllTempFiles in src/
Core/ File/ TempFileAdapter.php - Delete all temp files which have been created.
1 method overrides TempFileAdapter::deleteTempFile()
- DrupalTempFileAdapter::deleteTempFile in src/
Drupal/ File/ DrupalTempFileAdapter.php - Delete a temporary file.
File
- src/
Core/ File/ TempFileAdapter.php, line 90
Class
- TempFileAdapter
- A very basic temp file manager.
Namespace
Drupal\backup_migrate\Core\FileCode
public function deleteTempFile($filename) {
// Only delete files that were created by this manager.
if (in_array($filename, $this->tempfiles)) {
if (file_exists($filename)) {
if (is_writable($filename)) {
unlink($filename);
}
else {
throw new BackupMigrateException('Could not delete the temp file: %file because it is not writable', [
'%file' => $filename,
]);
}
}
// Remove the item from the list.
$this->tempfiles = array_diff($this->tempfiles, [
$filename,
]);
return;
}
throw new BackupMigrateException('Attempting to delete a temp file not managed by this codebase: %file', [
'%file' => $filename,
]);
}