protected function CompressionFilter::_bzipEncode in Backup and Migrate 8.4
BZip encode a file.
Parameters
\BackupMigrate\Core\File\BackupFileReadableInterface $from:
\BackupMigrate\Core\File\BackupFileWritableInterface $to:
Return value
bool
1 call to CompressionFilter::_bzipEncode()
- CompressionFilter::afterBackup in lib/
backup_migrate_core/ src/ Filter/ CompressionFilter.php - Run on a backup.
File
- lib/
backup_migrate_core/ src/ Filter/ CompressionFilter.php, line 253
Class
- CompressionFilter
- Class CompressionFilter.
Namespace
BackupMigrate\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_realpath($to
->realpath()));
$to
->setMeta('filesize', $fileszc);
}
}
return $success;
}