API15

Difference between revisions of "JArchiveBzip2/extract"

From Joomla! Documentation

< API15:JArchiveBzip2
(New page: ===Description=== Extract a Bzip2 compressed file to a given path <span class="editsection" style="font-size:76%;"> <nowiki>[</nowiki>[[Description:JArchiveBzip2/extract|Edit Descript...)
 
m (preparing for archive only)
 
(2 intermediate revisions by the same user not shown)
Line 2: Line 2:
 
Extract a Bzip2 compressed file to a given path
 
Extract a Bzip2 compressed file to a given path
  
<span class="editsection" style="font-size:76%;">
 
<nowiki>[</nowiki>[[Description:JArchiveBzip2/extract|Edit Descripton]]<nowiki>]</nowiki>
 
</span>
 
  
{{Description:JArchiveBzip2/extract}}
+
 
 +
<! removed transcluded page call, red link never existed >
  
 
===Syntax===
 
===Syntax===
Line 69: Line 67:
 
</source>
 
</source>
  
<span class="editsection" style="font-size:76%;">
+
 
<nowiki>[</nowiki>[[SeeAlso:JArchiveBzip2/extract|Edit See Also]]<nowiki>]</nowiki>
+
<! removed transcluded page call, red link never existed >
</span>
 
{{SeeAlso:JArchiveBzip2/extract}}
 
  
 
===Examples===
 
===Examples===
<CodeExamplesForm />
+
=== Code Examples ===
 
<dpl>
 
<dpl>
 
  noresultsheader=\n
 
  noresultsheader=\n
 
  category=extract
 
  category=extract
 
  category=JArchiveBzip2
 
  category=JArchiveBzip2
  category=CodeExample
+
  namespace=CodeExample
 
  category=MethodExample
 
  category=MethodExample
 
  include=*
 
  include=*
 
  format= ,,,
 
  format= ,,,
 
</dpl>
 
</dpl>
 +
[[Category:Archived pages API15]]

Latest revision as of 19:18, 24 March 2017

The "API15" namespace is an archived namespace. This page contains information for a Joomla! version which is no longer supported. It exists only as a historical reference, it will not be improved and its content may be incomplete and/or contain broken links.

Description[edit]

Extract a Bzip2 compressed file to a given path


<! removed transcluded page call, red link never existed >

Syntax[edit]

extract($archive, $destination, $options=array())
Parameter Name Default Value Description
$archive $archive Path to Bzip2 archive to extract
$destination $destination Path to extract archive to
$options array() $options Extraction options [unused]

Returns[edit]

boolean True if successful

Defined in[edit]

libraries/joomla/filesystem/archive/bzip2.php

Importing[edit]

jimport( 'joomla.filesystem.archive.bzip2' );

Source Body[edit]

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'));
        }

        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);
        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[edit]

Code Examples[edit]