protected function CompressionFilter::gzipEncode in Backup and Migrate 5.0.x
Gzip 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::gzipEncode()
- CompressionFilter::afterBackup in src/
Core/ Filter/ CompressionFilter.php - Run on a backup.
File
- src/
Core/ Filter/ CompressionFilter.php, line 191
Class
Namespace
Drupal\backup_migrate\Core\FilterCode
protected function gzipEncode(BackupFileReadableInterface $from, BackupFileWritableInterface $to) {
$success = FALSE;
if (!$success && function_exists("gzopen")) {
if (($fp_out = gzopen($to
->realpath(), 'wb9')) && $from
->openForRead()) {
while ($data = $from
->readBytes(1024 * 512)) {
gzwrite($fp_out, $data);
}
$success = TRUE;
$from
->close();
gzclose($fp_out);
// Get the compressed filesize and set it.
$fileszc = filesize(\Drupal::service('file_system')
->realpath($to
->realpath()));
$to
->setMeta('filesize', $fileszc);
}
}
return $success;
}