You are here

function _backup_migrate_zip_decode in Backup and Migrate 5.2

Zip decode a file.

1 call to _backup_migrate_zip_decode()
backup_migrate_file_decompress in includes/files.inc
Decompress a file with the given settings. Also updates settings to reflect new file mime and file extension.

File

includes/files.inc, line 327
General file handling code for Backup and Migrate.

Code

function _backup_migrate_zip_decode($source, $dest, $filename) {
  $success = FALSE;
  $zip = new ZipArchive();
  if (class_exists('ZipArchive')) {
    if (($fp_out = fopen($dest, "w")) && $zip
      ->open($source) && ($fp_in = $zip
      ->getStream($filename))) {
      while (!feof($fp_in)) {
        fwrite($fp_out, fread($fp_in, 1024 * 512));
      }
      $success = TRUE;
    }
    else {
      $error = TRUE;
    }
    @fclose($fp_in);
    @fclose($fp_out);
  }
  return $success;
}