From 6b349de77441365e6581070bddeedd2033c3a412 Mon Sep 17 00:00:00 2001 From: Marcus Boerger Date: Tue, 15 May 2007 16:28:15 +0000 Subject: [PATCH] - Fix compalg argument handling and merge it to preliminary phar command - Improve command info --- ext/phar/phar.php | 25 ++++++++++++++++++++++++- ext/phar/phar/pharcommand.inc | 27 +++++++++++++++++++++------ 2 files changed, 45 insertions(+), 7 deletions(-) diff --git a/ext/phar/phar.php b/ext/phar/phar.php index d5d8456889..f73c7bec86 100644 --- a/ext/phar/phar.php +++ b/ext/phar/phar.php @@ -423,6 +423,29 @@ class PharCommand extends CLICommand } } + static function cli_arg_typ_compalg($arg, $cfg) + { + $arg = self::cli_arg_typ_select($arg, $cfg); + switch($arg) + { + case 'auto': + if (extension_loaded('zlib')) + { + $arg = 'gz'; + } + else if (extension_loaded('bz2')) + { + $arg = 'bz2'; + } + else + { + $arg = '0'; + } + break; + } + return $arg; + } + static function cli_cmd_inf_pack() { return "Pack files into a PHAR archive."; @@ -432,7 +455,7 @@ class PharCommand extends CLICommand { return array( 'a' => array('typ'=>'alias', 'val'=>'newphar', 'required'=>1, 'inf'=>' Provide an alias name for the phar file.'), - 'c' => array('typ'=>'select', 'val'=>NULL, 'inf'=>' Compression algorithmus.', 'select'=>array('gz'=>'GZip compression','gzip'=>'GZip compression','bzip2'=>'BZip2 compression','bz'=>'BZip2 compression','bz2'=>'BZip2 compression','0'=>'No compression','none'=>'No compression')), + 'c' => array('typ'=>'compalg', 'val'=>NULL, 'inf'=>' Compression algorithmus.', 'select'=>array('gz'=>'GZip compression','gzip'=>'GZip compression','bzip2'=>'BZip2 compression','bz'=>'BZip2 compression','bz2'=>'BZip2 compression','0'=>'No compression','none'=>'No compression','auto'=>'Automatically select compression algorithm')), 'f' => array('typ'=>'pharnew', 'val'=>NULL, 'required'=>1, 'inf'=>' Specifies the phar file to work on.'), 'h' => array('typ'=>'select', 'val'=>NULL, 'inf'=>' Selects the hash algorithmn.', 'select'=>array('md5'=>'MD5','sha1'=>'SHA1','sha256'=>'SHA256','sha512'=>'SHA512')), 'i' => array('typ'=>'regex', 'val'=>NULL, 'inf'=>' Specifies a regular expression for input files.'), diff --git a/ext/phar/phar/pharcommand.inc b/ext/phar/phar/pharcommand.inc index 02c012768a..a9ff152d5f 100755 --- a/ext/phar/phar/pharcommand.inc +++ b/ext/phar/phar/pharcommand.inc @@ -140,7 +140,7 @@ class PharCommand extends CLICommand static function cli_arg_typ_compalg($arg, $cfg) { - $arg = cli_cmd_typ_select($arg, $cfg); + $arg = self::cli_arg_typ_select($arg, $cfg); switch($arg) { case 'auto': @@ -157,7 +157,6 @@ class PharCommand extends CLICommand $arg = '0'; } break; - case 'bz2': } return $arg; } @@ -595,11 +594,11 @@ class PharCommand extends CLICommand if (!$hash) { - $infos['Hash'] = 'NONE'; + $infos['Hash-type'] = 'NONE'; } else { - $infos['Hash Type'] = $hash['hash_type']; + $infos['Hash-type'] = $hash['hash_type']; $infos['Hash'] = $hash['hash']; } @@ -609,6 +608,7 @@ class PharCommand extends CLICommand $ccount = 0; $ucount = 0; $mcount = 0; + $compalg = array('GZ'=>0, 'BZ2'=>0); foreach(new RecursiveIteratorIterator($phar) as $ent) { @@ -616,11 +616,22 @@ class PharCommand extends CLICommand if ($ent->isCompressed()) { $ccount++; + $csize += $ent->getCompressedSize(); + if ($ent->isCompressedGZ()) + { + $compalg['GZ']++; + } + else if ($ent->isCompressedBZIP2()) + { + $compalg['BZ2']++; + } } else { $ucount++; + $csize += $ent->getSize(); } + $usize += $ent->getSize(); if ($ent->hasMetadata()) { $mcount++; @@ -628,8 +639,12 @@ class PharCommand extends CLICommand } $infos['Entries'] = $count; - $infos['Compressed'] = $ccount; - $infos['Uncompressed'] = $ucount; + $infos['Uncompressed-files'] = $ucount; + $infos['Compressed-files'] = $ccount; + $infos['Compressed-gz'] = $compalg['GZ']; + $infos['Compressed-bz2'] = $compalg['BZ2']; + $infos['Uncompressed-size'] = $usize; + $infos['Compressed-size'] = $csize; $infos['Metadata'] = $mcount; $l = 0; -- 2.40.0