protected function CompressionFilter::bzipEncode in Backup and Migrate 5.0.x
BZip encode a file.
Parameters
\Drupal\backup_migrate\Core\File\BackupFileReadableInterface $from:
\Drupal\backup_migrate\Core\File\BackupFileWritableInterface $to:
Return value
bool
1 call to CompressionFilter::bzipEncode()
- CompressionFilter::afterBackup in src/
Core/ Filter/ CompressionFilter.php - Run on a backup.
File
- src/
Core/ Filter/ CompressionFilter.php, line 245
Class
Namespace
Drupal\backup_migrate\Core\FilterCode
protected function bzipEncode(BackupFileReadableInterface $from, BackupFileWritableInterface $to) {
$success = FALSE;
if (!$success && function_exists("bzopen")) {
if (($fp_out = bzopen($to
->realpath(), 'w')) && $from
->openForRead()) {
while ($data = $from
->readBytes(1024 * 512)) {
bzwrite($fp_out, $data);
}
$success = TRUE;
$from
->close();
bzclose($fp_out);
// Get the compressed filesize and set it.
$fileszc = filesize(\Drupal::service('file_system')
->realpath($to
->realpath()));
$to
->setMeta('filesize', $fileszc);
}
}
return $success;
}