You are here

protected function CompressionFilter::_ZipDecode in Backup and Migrate 8.4

Gzip decode a file.

Parameters

\BackupMigrate\Core\File\BackupFileReadableInterface $from:

\BackupMigrate\Core\File\BackupFileWritableInterface $to:

Return value

bool

1 call to CompressionFilter::_ZipDecode()
CompressionFilter::beforeRestore in lib/backup_migrate_core/src/Filter/CompressionFilter.php
Run on a restore.

File

lib/backup_migrate_core/src/Filter/CompressionFilter.php, line 333

Class

CompressionFilter
Class CompressionFilter.

Namespace

BackupMigrate\Core\Filter

Code

protected function _ZipDecode(BackupFileReadableInterface $from, BackupFileWritableInterface $to) {
  $success = FALSE;
  if (class_exists('ZipArchive')) {
    $zip = new \ZipArchive();
    if ($zip
      ->open(drupal_realpath($from
      ->realpath()))) {
      $filename = $zip
        ->getNameIndex(0);
      if ($fp_in = $zip
        ->getStream($filename)) {
        while (!feof($fp_in)) {
          $to
            ->write(fread($fp_in, 1024 * 512));
        }
        fclose($fp_in);
        $success = $to
          ->close();
      }
    }
    return $success;
  }
}