Last active
December 14, 2015 10:37
Find total uncompressed size of a zip archive
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env php | |
<?php | |
$zip = new ZipArchive(); | |
if ($zip->open('name.zip') === true) { | |
var_dump(getTotalUncompressedSize($zip)); | |
$zip->close(); | |
} | |
function getTotalUncompressedSize(ZipArchive $zip) | |
{ | |
$totalSize = 0; | |
for ($i = 0; $i < $zip->numFiles; $i++) { | |
$fileStats = $zip->statIndex($i); | |
$totalSize += $fileStats['size']; | |
} | |
return $totalSize; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment