Source for file tar.php
Documentation is available at tar.php
* @package Joomla.Platform
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
jimport('joomla.filesystem.folder');
* Tar format adapter for the JArchive class
* This class is inspired from and draws heavily in code and concept from the Compress package of
* The Horde Project <http://www.horde.org>
* @contributor Michael Slusarz <slusarz@horde.org>
* @contributor Michael Cochrane <mike@graftonhall.co.nz>
* @package Joomla.Platform
0x33 =>
'Character special file',
0x34 =>
'Block special file',
0x36 =>
'FIFO special file',
0x37 =>
'Contiguous file');
* Tar file metadata array
private $_metadata =
null;
* Extract a ZIP compressed file to a given path
* @param string $archive Path to ZIP archive to extract
* @param string $destination Path to extract archive into
* @param array $options Extraction options [unused]
* @return boolean True if successful
* @throws RuntimeException
public function extract($archive, $destination, array $options =
array())
throw
new RuntimeException('Unable to read archive');
for ($i =
0, $n =
count($this->_metadata); $i <
$n; $i++
)
if ($type ==
'file' ||
$type ==
'unix file')
$buffer =
$this->_metadata[$i]['data'];
$path =
JPath::clean($destination .
'/' .
$this->_metadata[$i]['name']);
// Make sure the destination folder exists
throw
new RuntimeException('Unable to create destination');
throw
new RuntimeException('Unable to write entry');
* Tests whether this adapter can unpack files on this computer.
* @return boolean True if supported
* Get the list of files/data from a Tar archive buffer.
* @param string &$data The Tar archive buffer.
* @return array Archive metadata array
* KEY: Position in the array
* VALUES: 'attr' -- File attributes
* 'data' -- Raw file contents
* 'date' -- File modification time
* 'size' -- Original file size
while ($position <
strlen($data))
"a100filename/a8mode/a8uid/a8gid/a12size/a12mtime/a8checksum/Ctypeflag/a100link/a6magic/a2version/a32uname/a32gname/a8devmajor/a8devminor",
throw
new RuntimeException('Unable to decompress data');
$contents =
substr($data, $position, octdec($info['size']));
$position +=
ceil(octdec($info['size']) /
512) *
512;
'date' =>
octdec($info['mtime']),
'name' =>
trim($info['filename']),
'size' =>
octdec($info['size']),
'type' => isset
($this->_types[$info['typeflag']]) ?
$this->_types[$info['typeflag']] :
null);
if (($info['typeflag'] ==
0) ||
($info['typeflag'] ==
0x30) ||
($info['typeflag'] ==
0x35))
$file['data'] =
$contents;
$file['attr'] =
(($info['typeflag'] ==
0x35) ?
'd' :
'-') .
(($mode & 0x400) ?
'r' :
'-') .
(($mode & 0x200) ?
'w' :
'-') .
(($mode & 0x100) ?
'x' :
'-') .
(($mode & 0x040) ?
'r' :
'-') .
(($mode & 0x020) ?
'w' :
'-') .
(($mode & 0x010) ?
'x' :
'-') .
(($mode & 0x004) ?
'r' :
'-') .
(($mode & 0x002) ?
'w' :
'-') .
(($mode & 0x001) ?
'x' :
'-');
$this->_metadata =
$return_array;
Documentation generated on Tue, 19 Nov 2013 15:15:20 +0100 by phpDocumentor 1.4.3