API15:JArchiveGzip/extract
From Joomla! Documentation
Description
Extract a Gzip compressed file to a given path
<! removed transcluded page call, red link never existed >
Syntax
extract($archive, $destination, $options=array())
| Parameter Name | Default Value | Description |
|---|---|---|
| $archive | $archive Path to ZIP archive to extract | |
| $destination | $destination Path to extract archive to | |
| $options | array() | $options Extraction options [unused] |
Returns
boolean True if successful
Defined in
libraries/joomla/filesystem/archive/gzip.php
Importing
jimport( 'joomla.filesystem.archive.gzip' );
Source Body
function extract($archive, $destination, $options = array ())
{
// Initialize variables
$this->_data = null;
if (!extension_loaded('zlib')) {
$this->set('error.message', 'Zlib Not Supported');
return JError::raiseWarning(100, $this->get('error.message'));
}
if (!$this->_data = JFile::read($archive)) {
$this->set('error.message', 'Unable to read archive');
return JError::raiseWarning(100, $this->get('error.message'));
}
$position = $this->_getFilePosition();
$buffer = gzinflate(substr($this->_data, $position, strlen($this->_data) - $position));
if (empty ($buffer)) {
$this->set('error.message', 'Unable to decompress data');
return JError::raiseWarning(100, $this->get('error.message'));
}
if (JFile::write($destination, $buffer) === false) {
$this->set('error.message', 'Unable to write archive');
return JError::raiseWarning(100, $this->get('error.message'));
}
return true;
}
<! removed transcluded page call, red link never existed >
Examples
Code Examples