|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2011-01-27 14:54 UTC] rquadling@php.net
Description: ------------ ext/zip internally uses several constants to identify the nature of the compressed content. Not all of these are exposed, though one of them is documented (ZipArchive::CM_BZIP2). The attached patch for ext/zip/php_zip.c adds the missing constants. Once this is committed, I can update the documentation with the others (LZMA, TERSE, LZ77, WAVPACK and PPMD). Patchesmissing_zip_constants.patch (last revision 2011-01-27 13:55 UTC by rquadling@php.net)Pull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 29 22:00:02 2025 UTC |
I took a file (an uncompressed WAV file) and compressed it using WinZip V15 using different algorithms. Using the following code ... <?php $zip = new ZipArchive; $zip->open('wav.zipx'); foreach(range(0, $zip->numFiles - 1) as $index) { print_r($stat = $zip->statIndex($index)); $zip->extractTo('.', array($stat['name'])); echo $zip->getStatusString(), PHP_EOL; } $zip->close(); Outputs ... Array ( [name] => WavPack.wav [index] => 0 [crc] => 1384274557 [size] => 154826 [mtime] => 1296208410 [comp_size] => 45366 [comp_method] => 97 ) Compression method not supported Array ( [name] => PPMD.wav [index] => 1 [crc] => 1384274557 [size] => 154826 [mtime] => 1296208410 [comp_size] => 100729 [comp_method] => 98 ) Compression method not supported Array ( [name] => LZMA.wav [index] => 2 [crc] => 1384274557 [size] => 154826 [mtime] => 1296208410 [comp_size] => 68162 [comp_method] => 14 ) Compression method not supported Array ( [name] => BZIP2.wav [index] => 3 [crc] => 1384274557 [size] => 154826 [mtime] => 1296208410 [comp_size] => 104633 [comp_method] => 12 ) Compression method not supported As you can see, 98, 97, 14 and 12 are all identified as the comp_method (correctly). None of these compression methods are supported by php_zip, but the constants should be present to allow determination of the method used. Interestingly WavPack was the best algorithm to use on uncompressed audio (which WinZip performed when I asked it to "compress to the smallest size"). I can send the zip file if needed (300K). I think it is important to remember that the zip files being accessed by php_zip may not have been produced by php_zip.