Source code for file /joomla/filesystem/archive.php
Documentation is available at archive.php
* @version $Id: archive.php 10381 2008-06-01 03:35:53Z pasamio $
* @package Joomla.Framework
* @copyright Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.
* @license GNU/GPL, see LICENSE.php
* Joomla! is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
* An Archive handling class
* @package Joomla.Framework
* @param string The name of the archive file
* @param string Directory to unpack into
* @return boolean True for success
function extract( $archivename, $extractdir)
jimport('joomla.filesystem.folder');
// check if a tar is embedded...gzip/bzip2 can just be plain files!
$result =
$adapter->extract($archivename, $extractdir);
$result =
$adapter->extract($archivename, $extractdir);
$untar =
true; // This format is a tarball gzip'd
case 'gz' :
// This may just be an individual file (e.g. sql script)
$tmpfname =
$config->getValue('config.tmp_path').
DS.
uniqid('gzip');
$gzresult =
$adapter->extract($archivename, $tmpfname);
$result =
$tadapter->extract($tmpfname, $extractdir);
$untar =
true; // This format is a tarball bzip2'd
case 'bz2' :
// This may just be an individual file (e.g. sql script)
$tmpfname =
$config->getValue('config.tmp_path').
DS.
uniqid('bzip2');
$bzresult =
$adapter->extract($archivename, $tmpfname);
$result =
$tadapter->extract($tmpfname, $extractdir);
if (!isset
($adapters[$type]))
// Try to load the adapter object
$class =
'JArchive'.
ucfirst($type);
$adapters[$type] =
new $class();
* @param string The name of the archive
* @param mixed The name of a single file or an array of files
* @param string The compression for the archive
* @param string Path to add within the archive
* @param string Path to remove within the archive
* @param boolean Automatically append the extension for the archive
* @param boolean Remove for source files
function create($archive, $files, $compress =
'tar', $addPath =
'', $removePath =
'', $autoExt =
false, $cleanUp =
false)
jimport( 'pear.archive_tar.Archive_Tar' );
$archive .=
'.'.
$compress;
$tar->createModify( $files, $addPath, $removePath );