10 defined(
'JPATH_PLATFORM') or die;
12 jimport('joomla.filesystem.file');
13 jimport('joomla.filesystem.stream');
30 private $_data = null;
44 public function extract($archive, $destination, array $options = array ())
48 if (!extension_loaded(
'bz2'))
50 if (class_exists(
'JError'))
56 throw new RuntimeException(
'The bz2 extension is not available.');
60 if (!isset($options[
'use_streams']) || $options[
'use_streams'] ==
false)
63 $this->_data = file_get_contents($archive);
67 if (class_exists(
'JError'))
73 throw new RuntimeException(
'Unable to read archive');
77 $buffer = bzdecompress($this->_data);
82 if (class_exists(
'JError'))
88 throw new RuntimeException(
'Unable to decompress data');
94 if (class_exists(
'JError'))
100 throw new RuntimeException(
'Unable to write archive');
111 $input->set(
'processingmethod',
'bz');
113 if (!$input->open($archive))
115 if (class_exists(
'JError'))
121 throw new RuntimeException(
'Unable to read archive (bz2)');
127 if (!$output->open($destination,
'w'))
131 if (class_exists(
'JError'))
137 throw new RuntimeException(
'Unable to write archive (bz2)');
143 $this->_data = $input->read($input->get(
'chunksize', 8196));
147 if (!$output->write($this->_data))
151 if (class_exists(
'JError'))
157 throw new RuntimeException(
'Unable to write archive (bz2)');
162 while ($this->_data);
178 public static function isSupported()
180 return extension_loaded(
'bz2');