You are here

function _backup_migrate_gzip_encode in Backup and Migrate 5.2

Same name and namespace in other branches
  1. 5 backup_migrate.module \_backup_migrate_gzip_encode()
  2. 6 backup_migrate.module \_backup_migrate_gzip_encode()

Gzip encode a file.

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

File

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

Code

function _backup_migrate_gzip_encode($source, $dest, $level = 9) {
  $success = FALSE;
  if (@function_exists("gzopen")) {
    if (($fp_out = gzopen($dest, 'wb' . $level)) && ($fp_in = fopen($source, 'rb'))) {
      while (!feof($fp_in)) {
        gzwrite($fp_out, fread($fp_in, 1024 * 512));
      }
      $success = TRUE;
    }
    @fclose($fp_in);
    @gzclose($fp_out);
  }
  return $success;
}