Source for file Archive.php
Documentation is available at Archive.php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
* HTTP::Download::Archive
* @author Michael Wallner <mike@php.net>
* @copyright 2003-2005 Michael Wallner
* @version CVS: $Id: Archive.php,v 1.4 2005/11/13 19:18:55 mike Exp $
* @link http://pear.php.net/package/HTTP_Download
require_once 'HTTP/Download.php';
require_once 'System.php';
* Helper class for sending Archives.
* @version $Revision: 1.4 $
class HTTP_Download_Archive
* Send a bunch of files or directories as an archive
* require_once 'HTTP/Download/Archive.php';
* HTTP_Download_Archive::send(
* @see Archive_Tar::createModify()
* @return mixed Returns true on success or PEAR_Error on failure.
* @param string $name name the sent archive should have
* @param mixed $files files/directories
* @param string $type archive type
* @param string $add_path path that should be prepended to the files
* @param string $strip_path path that should be stripped from the files
function send ($name, $files, $type = HTTP_DOWNLOAD_TGZ , $add_path = '', $strip_path = '')
switch ($type = strToUpper ($type))
include_once 'Archive/Tar.php';
$arc = &new Archive_Tar ($tmp);
include_once 'Archive/Tar.php';
$arc = &new Archive_Tar ($tmp, 'gz');
$content_type = 'x-gzip';
include_once 'Archive/Tar.php';
$arc = &new Archive_Tar ($tmp, 'bz2');
$content_type = 'x-bzip2';
include_once 'Archive/Zip.php';
$arc = &new Archive_Zip ($tmp);
'Archive type not supported: ' . $type,
$options = array ( 'add_path' => $add_path,
'remove_path' => $strip_path);
if (!$arc->create ($files, $options)) {
return PEAR ::raiseError ('Archive creation failed.');
if (!$e = $arc->createModify ($files, $add_path, $strip_path)) {
return PEAR ::raiseError ('Archive creation failed.');
$dl = &new HTTP_Download (array ('file' => $tmp));
$dl->setContentType ('application/' . $content_type);
Documentation generated on Wed, 31 Oct 2007 03:30:08 -0400 by phpDocumentor 1.4.0. PEAR Logo Copyright © PHP Group 2004.
|