Boost logo

Boost-Commit :

From: daniel_james_at_[hidden]
Date: 2008-07-21 03:41:23


Author: danieljames
Date: 2008-07-21 03:41:22 EDT (Mon, 21 Jul 2008)
New Revision: 47649
URL: http://svn.boost.org/trac/boost/changeset/47649

Log:
Return readable error message for unzip errors from raw files.
Text files modified:
   website/public_html/beta/common/code/boost_archive.php | 36 ++++++++++++++++++++++++++----------
   1 files changed, 26 insertions(+), 10 deletions(-)

Modified: website/public_html/beta/common/code/boost_archive.php
==============================================================================
--- website/public_html/beta/common/code/boost_archive.php (original)
+++ website/public_html/beta/common/code/boost_archive.php 2008-07-21 03:41:22 EDT (Mon, 21 Jul 2008)
@@ -138,16 +138,8 @@
         $file_handle = popen($unzip,'rb');
         fpassthru($file_handle);
         $exit_status = pclose($file_handle);
- if($exit_status != 0) {
- if($exit_status == 9) {
- echo "File not found.";
- }
- else {
- echo "Error extracting file: $exit_status";
- echo "<br>\n";
- echo "<code>".htmlentities($unzip)."</code>";
- }
- }
+ if($exit_status != 0)
+ echo 'Error extracting file: '.unzip_error($exit_status);
     }
     
     function content()
@@ -518,4 +510,28 @@
         print '<h1>404 Not Found</h1><p>File "' . $this->file_ . '"not found.</p>';
     }
 }
+
+// Return a readable error message for unzip exit state.
+
+function unzip_error($exit_status) {
+ switch($exit_status) {
+ case 0: return 'No error.';
+ case 1: return 'One or more warning errors were encountered.';
+ case 2: return 'A generic error in the zipfile format was detected.';
+ case 3: return 'A severe error in the zipfile format was detected.';
+ case 4: return 'Unzip was unable to allocate memory for one or more buffers during program initialization.';
+ case 5: return 'Unzip was unable to allocate memory or unable to obtain a tty to read the decryption password(s).';
+ case 6: return 'Unzip was unable to allocate memory during decompression to disk.';
+ case 7: return 'Unzip was unable to allocate memory during in-memory decompression.';
+ case 9: return 'The specified zipfiles were not found.';
+ case 10: return 'Invalid options were specified on the command line.';
+ case 11: return 'No matching files were found.';
+ case 50: return 'The disk is (or was) full during extraction.';
+ case 51: return 'The end of the ZIP archive was encountered prematurely.';
+ case 80: return 'The user aborted unzip prematurely with control-C (or similar).';
+ case 81: return 'Testing or extraction of one or more files failed due to unsupported compression methods or unsupported decryption.';
+ case 82: return 'No files were found due to bad decryption password(s).';
+ default: return 'Unknown unzip error code: ' + $exit_status;
+ }
+}
 ?>


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk