_drush_print_pdf_download_extract

  1. drupal
    1. 6 print_pdf.drush.inc function
    2. 7 print_pdf.drush.inc function
Drupal 7 _drush_print_pdf_download_extract($filename)

Helper to download and extract the zip/tar archive.

1 call to _drush_print_pdf_download_extract()

File

sites/all/modules/print/print_pdf/print_pdf.drush.inc, line 140
drush integration for print_pdf module PDF libraries download.

Code

function _drush_print_pdf_download_extract($filename) {
  $arch_ret = FALSE;

  if (drush_op('is_file', $filename)) {
    switch (drush_op('mime_content_type', $filename)) {
      case 1:
        $arch_ret = TRUE;
        break;
      case 'application/zip':
        // Decompress the zip archive
        $arch_ret = drush_shell_exec('unzip -qq -o ' . $filename);
        // ZIP archives usually get the access rights wrong
        drush_log(dt('@filename is a Zip file. Check the access permissions of the extracted files.', array('@filename' => $filename)), 'warning');
        break;
      case 'application/x-gzip':
        // Decompress the tar gz archive
        $arch_ret = drush_shell_exec('tar xzf ' . $filename);
        break;
      case 'application/x-bzip2':
        // Decompress the tar bz2 archive
        $arch_ret = drush_shell_exec('tar xjf ' . $filename);
        break;
    }
  }
  else {
    drush_log(dt('@filename not found.', array('@filename' => $filename)), 'error');
  }

  return $arch_ret;
}