1<?php 2/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ 3 4/** 5 * Base class for all the transformation writers that will generate one single 6 * file 7 * 8 * PHP versions 4 and 5 9 * 10 * This library is free software; you can redistribute it and/or 11 * modify it under the terms of the GNU Lesser General Public 12 * License as published by the Free Software Foundation; either 13 * version 2.1 of the License, or (at your option) any later version. 14 * 15 * This library is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 * Lesser General Public License for more details. 19 * 20 * You should have received a copy of the GNU Lesser General Public 21 * License along with this library; if not, write to the Free Software 22 * Foundation, Inc., 59 Temple Place, Suite 330,Boston,MA 02111-1307 USA 23 * 24 * @category File Formats 25 * @package File_Archive 26 * @author Vincent Lascaux <vincentlascaux@php.net> 27 * @copyright 1997-2005 The PHP Group 28 * @license http://www.gnu.org/copyleft/lesser.html LGPL 29 * @version CVS: $Id: Archive.php,v 1.12 2005/06/02 12:24:43 vincentlascaux Exp $ 30 * @link http://pear.php.net/package/File_Archive 31 */ 32 33require_once "File/Archive/Writer.php"; 34 35/** 36 * Base class for all the transformation writers that will generate one single 37 * file 38 */ 39class File_Archive_Writer_Archive extends File_Archive_Writer 40{ 41 /** 42 * @var File_Archive_Writer The compressed data will be written to this 43 * writer 44 * @access protected 45 */ 46 var $innerWriter; 47 48 /** 49 * @var bool If true, the innerWriter will be closed when closing this 50 * @access private 51 */ 52 var $autoClose; 53 54 /** 55 * @param String $filename Name to give to the archive (the name will 56 * be used by the inner writer) 57 * If $filename is null, the innerWriter is considered already 58 * opened (and thus newFile will not be called) 59 * @param File_Archive_Writer $innerWriter The inner writer to which the 60 * compressed data will be written 61 * @param array $stat The stat of the archive (see the PHP stat() function). 62 * No element are required in this array 63 * @param bool $autoClose Indicate if the inner writer must be closed when 64 * closing this 65 */ 66 function File_Archive_Writer_Archive($filename, &$innerWriter, 67 $stat = array(), $autoClose = true) 68 { 69 $this->innerWriter =& $innerWriter; 70 $this->autoClose = $autoClose; 71 if ($filename !== null) { 72 $this->innerWriter->newFile($filename, $stat, $this->getMime()); 73 } 74 } 75 76//MUST REWRITE FUNCTIONS 77 //function newFile($filename, $stat, $mime) { } 78 79 /** 80 * @return the MIME extension of the files generated by this writer 81 */ 82 function getMime() { return "application/octet-stream"; } 83 84 /** 85 * @see File_Archive_Writer::close() 86 */ 87 function close() 88 { 89 if ($this->autoClose) { 90 return $this->innerWriter->close(); 91 } 92 } 93// function writeData($data) 94 95//SHOULD REWRITE FUNCTIONS 96// function writeFile($filename) 97} 98 99?>