public function compress($ext = 'gz')
{
if ($ext == 'bz') {
$ext .= '2';
}
switch ($ext) {
case 'gz':
$newArchive = Compress\Gzip::compress($this->fullpath);
break;
case 'tgz':
$tmpArchive = Compress\Gzip::compress($this->fullpath);
$newArchive = str_replace('.tar.gz', '.tgz', $tmpArchive);
rename($tmpArchive, $newArchive);
break;
case 'bz2':
$newArchive = Compress\Bzip2::compress($this->fullpath);
break;
case 'tbz':
$tmpArchive = Compress\Bzip2::compress($this->fullpath);
$newArchive = str_replace('.tar.bz2', '.tbz', $tmpArchive);
rename($tmpArchive, $newArchive);
break;
case 'tbz2':
$tmpArchive = Compress\Bzip2::compress($this->fullpath);
$newArchive = str_replace('.tar.bz2', '.tbz2', $tmpArchive);
rename($tmpArchive, $newArchive);
break;
default:
$newArchive = $this->fullpath;
}
if (file_exists($this->fullpath)) {
unlink($this->fullpath);
}
self::__construct($newArchive);
return $this;
}