Source for file gzip.php
Documentation is available at gzip.php
* @package Joomla.Platform
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
* Gzip format adapter for the JArchive class
* This class is inspired from and draws heavily in code and concept from the Compress package of
* The Horde Project <http://www.horde.org>
* @contributor Michael Slusarz <slusarz@horde.org>
* @contributor Michael Cochrane <mike@graftonhall.co.nz>
* @package Joomla.Platform
private $_flags =
array('FTEXT' =>
0x01, 'FHCRC' =>
0x02, 'FEXTRA' =>
0x04, 'FNAME' =>
0x08, 'FCOMMENT' =>
0x10);
* Extract a Gzip compressed file to a given path
* @param string $archive Path to ZIP archive to extract
* @param string $destination Path to extract archive to
* @param array $options Extraction options [unused]
* @return boolean True if successful
* @throws RuntimeException
public function extract($archive, $destination, array $options =
array ())
throw
new RuntimeException('The zlib extension is not available.');
if (!isset
($options['use_streams']) ||
$options['use_streams'] ==
false)
throw
new RuntimeException('Unable to read archive');
throw
new RuntimeException('Unable to decompress data');
if (JFile::write($destination, $buffer) ===
false)
throw
new RuntimeException('Unable to write archive');
$input->set('processingmethod', 'gz');
if (!$input->open($archive))
throw
new RuntimeException('Unable to read archive (gz)');
if (!$output->open($destination, 'w'))
throw
new RuntimeException('Unable to write archive (gz)');
$this->_data =
$input->read($input->get('chunksize', 8196));
if (!$output->write($this->_data))
throw
new RuntimeException('Unable to write file (gz)');
* Tests whether this adapter can unpack files on this computer.
* @return boolean True if supported
* Get file data offset for archive
* @return integer Data position marker for archive
* @throws RuntimeException
// Gzipped file... unpack it first
$info =
@ unpack('CCM/CFLG/VTime/CXFL/COS', substr($this->_data, $position +
2));
throw
new RuntimeException('Unable to decompress data.');
if ($info['FLG'] & $this->_flags['FEXTRA'])
$XLEN =
unpack('vLength', substr($this->_data, $position +
0, 2));
if ($info['FLG'] & $this->_flags['FNAME'])
$filenamePos =
strpos($this->_data, "\x0", $position);
$position =
$filenamePos +
1;
if ($info['FLG'] & $this->_flags['FCOMMENT'])
$commentPos =
strpos($this->_data, "\x0", $position);
$position =
$commentPos +
1;
if ($info['FLG'] & $this->_flags['FHCRC'])
$hcrc =
unpack('vCRC', substr($this->_data, $position +
0, 2));
Documentation generated on Tue, 19 Nov 2013 15:04:12 +0100 by phpDocumentor 1.4.3