You are here

function imce_unzip_err in IMCE unzip 6

Same name and namespace in other branches
  1. 7 imce_unzip.module \imce_unzip_err()

Nice error messages for zip. See http://php.net/manual/en/function.zip-open.php.

1 call to imce_unzip_err()
_imce_unzip_file_unzip in ./imce_unzip.module
Unzip the files and check extensions.

File

./imce_unzip.module, line 291
Main functions for IMCE unzip module

Code

function imce_unzip_err($errno) {
  $zip_errors = array(
    'ZIPARCHIVE::ER_MULTIDISK' => t('Multi-disk zip archives not supported.'),
    'ZIPARCHIVE::ER_RENAME' => t('Renaming temporary file failed.'),
    'ZIPARCHIVE::ER_CLOSE' => t('Closing zip archive failed'),
    'ZIPARCHIVE::ER_SEEK' => t('Seek error'),
    'ZIPARCHIVE::ER_READ' => t('Read error'),
    'ZIPARCHIVE::ER_WRITE' => t('Write error'),
    'ZIPARCHIVE::ER_CRC' => t('CRC error'),
    'ZIPARCHIVE::ER_ZIPCLOSED' => t('Containing zip archive was closed'),
    'ZIPARCHIVE::ER_NOENT' => t('No such file.'),
    'ZIPARCHIVE::ER_EXISTS' => t('File already exists'),
    'ZIPARCHIVE::ER_OPEN' => t("Can't open file"),
    'ZIPARCHIVE::ER_TMPOPEN' => t('Failure to create temporary file.'),
    'ZIPARCHIVE::ER_ZLIB' => t('Zlib error'),
    'ZIPARCHIVE::ER_MEMORY' => t('Memory allocation failure'),
    'ZIPARCHIVE::ER_CHANGED' => t('Entry has been changed'),
    'ZIPARCHIVE::ER_COMPNOTSUPP' => t('Compression method not supported.'),
    'ZIPARCHIVE::ER_EOF' => t('Premature EOF'),
    'ZIPARCHIVE::ER_INVAL' => t('Invalid argument'),
    'ZIPARCHIVE::ER_NOZIP' => t('Not a zip archive'),
    'ZIPARCHIVE::ER_INTERNAL' => t('Internal error'),
    'ZIPARCHIVE::ER_INCONS' => t('Zip archive inconsistent'),
    'ZIPARCHIVE::ER_REMOVE' => t("Can't remove file"),
    'ZIPARCHIVE::ER_DELETED' => t('Entry has been deleted'),
  );
  $errmsg = 'unknown';
  foreach ($zip_errors as $const_name => $error_message) {
    if (defined($const_name) and constant($const_name) === $errno) {
      return t('Zip File Function error: %error', array(
        '%error' => $error_message,
      ));
    }
  }
  return t('Zip File Function error: unknown - %error', array(
    '%error' => $errno,
  ));
}