| Previous CloneSet | Next CloneSet | Back to Main Report |
| Clone Mass | Clones in CloneSet | Parameter Count | Clone Similarity | Syntax Category [Sequence Length] |
|---|---|---|---|---|
| 57 | 2 | 6 | 0.995 | class_member |
| Clone Abstraction | Parameter Bindings |
| Clone Instance (Click to see clone) | Line Count | Source Line | Source File |
|---|---|---|---|
| 1 | 57 | 59 | libraries/joomla/filesystem/archive/bzip2.php |
| 2 | 57 | 56 | libraries/joomla/filesystem/archive/gzip.php |
| ||||
/**
* Extract a Bzip2 compressed file to a given path
*
* @access public
* @param string $archive Path to Bzip2 archive to extract
* @param string $destination Path to extract archive to
* @param array $options Extraction options [unused]
* @return boolean True if successful
* @since 1.5
*/
function extract($archive, $destination, $options= array()) {
// Initialize variables
$this->_data = NULL;
if (!extension_loaded('bz2')) {
$this->set('error.message', 'BZip2 Not Supported');
return JError::raiseWarning(100, $this->get('error.message'));
}
/* // old style: read the whole file and then parse it
if (!$this->_data = JFile::read($archive)) {
$this->set('error.message', 'Unable to read archive');
return JError::raiseWarning(100, $this->get('error.message'));
}
$buffer = bzdecompress($this->_data);
unset($this->_data);
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'));
}
//*/
// New style! streams!
$input= & JFactory::getStream();
$input->set('processingmethod','bz'); // use bzip
if (!$input->open($archive)) {
$this->set('error.message', 'Unable to read archive (bz2)');
return JError::raiseWarning(100, $this->get('error.message'));
}
$output= & JFactory::getStream();
if (!$output->open($destination, 'w')) {
$this->set('error.message', 'Unable to write archive (bz2)');
$input->close(); // close the previous file
return JError::raiseWarning(100, $this->get('error.message'));
}
$written= 0;
do {
$this->_data = $input->read($input->get('chunksize', 8196));
if ($this->_data) {
if (!$output->write($this->_data)) {
$this->set('error.message', 'Unable to write file (bz2)');
return JError::raiseWarning(100, $this->get('error.message'));
}
}
} while ($this->_data);
$output->close();
$input->close();
return TRUE;
}
|
| ||||
/**
* Extract a Gzip compressed file to a given path
*
* @access public
* @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
* @since 1.5
*/
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;
*/
// New style! streams!
$input= & JFactory::getStream();
$input->set('processingmethod','gz'); // use gz
if (!$input->open($archive)) {
$this->set('error.message', 'Unable to read archive (gz)');
return JError::raiseWarning(100, $this->get('error.message'));
}
$output= & JFactory::getStream();
if (!$output->open($destination, 'w')) {
$this->set('error.message', 'Unable to write archive (gz)');
$input->close(); // close the previous file
return JError::raiseWarning(100, $this->get('error.message'));
}
$written= 0;
do {
$this->_data = $input->read($input->get('chunksize', 8196));
if ($this->_data) {
if (!$output->write($this->_data)) {
$this->set('error.message', 'Unable to write file (gz)');
return JError::raiseWarning(100, $this->get('error.message'));
}
}
} while ($this->_data);
$output->close();
$input->close();
return TRUE;
}
|
| |||
/**
* Extract a Bzip2 compressed file to a given path
*
* @access public
* @param string $archive Path to Bzip2 archive to extract
* @param string $destination Path to extract archive to
* @param array $options Extraction options [unused]
* @return boolean True if successful
* @since 1.5
*/
/**
* Extract a Gzip compressed file to a given path
*
* @access public
* @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
* @since 1.5
*/
function extract($archive,$destination,$options=array()) {
// Initialize variables
$this->_data =NULL;
if (!extension_loaded( [[#variable57f73760]])) {
$this->set('error.message', [[#variable57f736c0]]);
return JError::raiseWarning(100,$this->get('error.message'));
}
/* // old style: read the whole file and then parse it
if (!$this->_data = JFile::read($archive)) {
$this->set('error.message', 'Unable to read archive');
return JError::raiseWarning(100, $this->get('error.message'));
}
$buffer = bzdecompress($this->_data);
unset($this->_data);
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'));
}
//*/
/*
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;
*/
// New style! streams!
$input= &JFactory::getStream();
$input->set('processingmethod', [[#variable57f73600]]); // use bzip // use gz
if (!$input->open($archive)) {
$this->set('error.message', [[#variable57f735e0]]);
return JError::raiseWarning(100,$this->get('error.message'));
}
$output= &JFactory::getStream();
if (!$output->open($destination,'w')) {
$this->set('error.message', [[#variable57f73540]]);
$input->close(); // close the previous file
return JError::raiseWarning(100,$this->get('error.message'));
}
$written=0;
do {
$this->_data =$input->read($input->get('chunksize',8196));
if ($this->_data) {
if (!$output->write($this->_data)) {
$this->set('error.message', [[#variable57f735a0]]);
return JError::raiseWarning(100,$this->get('error.message'));
}
}
} while ($this->_data);
$output->close();
$input->close();
return TRUE;
}
|
| CloneAbstraction |
| Parameter Index | Clone Instance | Parameter Name | Value |
|---|---|---|---|
| 1 | 1 | [[#57f73760]] | 'bz2' |
| 1 | 2 | [[#57f73760]] | 'zlib' |
| 2 | 1 | [[#57f736c0]] | 'BZip2 Not Supported' |
| 2 | 2 | [[#57f736c0]] | 'Zlib Not Supported' |
| 3 | 1 | [[#57f73600]] | 'bz' |
| 3 | 2 | [[#57f73600]] | 'gz' |
| 4 | 1 | [[#57f735e0]] | 'Unable to read archive (bz2)' |
| 4 | 2 | [[#57f735e0]] | 'Unable to read archive (gz)' |
| 5 | 1 | [[#57f73540]] | 'Unable to write archive (bz2)' |
| 5 | 2 | [[#57f73540]] | 'Unable to write archive (gz)' |
| 6 | 1 | [[#57f735a0]] | 'Unable to write file (bz2)' |
| 6 | 2 | [[#57f735a0]] | 'Unable to write file (gz)' |