makeBzip2('./','./toto.bzip2'); var_export($test->infosBzip2('./toto.bzip2')); $test->extractBzip2('./toto.bzip2', './new/'); **/ function makeBzip2($src, $dest=false) { $Bzip2 = bzcompress((strpos(chr(0),$src) ? file_get_contents ($src) : $src), 6); if (empty($dest)) return $Bzip2; elseif (file_put_contents($dest, $Bzip2)) return $dest; return false; } function infosBzip2 ($src, $data=true) { $data = $this->extractBzip2 ($src); $content = array( 'UnCompSize'=>strlen($data), 'Size'=>filesize($src), 'Ratio'=>strlen($data) ? round(100 - filesize($src) / strlen($data)*100, 1) : false,); if ($data) $content['Data'] = $data; return $content; } function extractBzip2($src, $dest=false) { $bz = bzopen($src, "r"); $data = ''; while (!feof($bz)) $data .= bzread($bz, 1024*1024); bzclose($bz); if (empty($dest)) return $data; elseif (file_put_contents($dest, $data)) return $dest; return false; } } ?>