CloneSet88


Previous CloneSetNext CloneSetBack to Main Report
Clone
Mass
Clones in
CloneSet
Parameter
Count
Clone
Similarity
Syntax Category
[Sequence Length]
57260.995class_member
Clone AbstractionParameter Bindings
Clone Instance
(Click to see clone)
Line CountSource Line
Source File
15759
libraries/joomla/filesystem/archive/bzip2.php
25756
libraries/joomla/filesystem/archive/gzip.php
Clone Instance
1
Line Count
57
Source Line
59
Source File
libraries/joomla/filesystem/archive/bzip2.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;
              }


Clone Instance
2
Line Count
57
Source Line
56
Source File
libraries/joomla/filesystem/archive/gzip.php

        /**
        * 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;
              }


Clone AbstractionParameter Count: 6Parameter Bindings

/**
        * 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 Bindings
Parameter
Index
Clone
Instance
Parameter
Name
Value
11[[#57f73760]]
'bz2' 
12[[#57f73760]]
'zlib' 
21[[#57f736c0]]
'BZip2 Not Supported' 
22[[#57f736c0]]
'Zlib Not Supported' 
31[[#57f73600]]
'bz' 
32[[#57f73600]]
'gz' 
41[[#57f735e0]]
'Unable to read archive (bz2)' 
42[[#57f735e0]]
'Unable to read archive (gz)' 
51[[#57f73540]]
'Unable to write archive (bz2)' 
52[[#57f73540]]
'Unable to write archive (gz)' 
61[[#57f735a0]]
'Unable to write file (bz2)' 
62[[#57f735a0]]
'Unable to write file (gz)'