Source for file MemoryArchive.php
Documentation is available at MemoryArchive.php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
* Base class for all the archiveWriters that can only work on complete files
* (the write data function may be called with small chunks of data)
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330,Boston,MA 02111-1307 USA
* @author Vincent Lascaux <vincentlascaux@php.net>
* @copyright 1997-2005 The PHP Group
* @license http://www.gnu.org/copyleft/lesser.html LGPL
* @version CVS: $Id: MemoryArchive.php,v 1.10 2005/04/08 10:18:06 vincentlascaux Exp $
* @link http://pear.php.net/package/File_Archive
require_once "Archive.php";
require_once "Memory.php";
* Base class for all the archiveWriters that can only work on complete files
* (the write data function may be called with small chunks of data)
class File_Archive_Writer_MemoryArchive extends File_Archive_Writer_Archive
* @var File_Archive_Writer_Memory A buffer where the data will be put
* waiting for the file to be complete
var $memoryWriter = null;
* @var string Name of the file which data are coming
var $currentFilename = null;
* @var array Stats of the file which data are coming
* @var string URL of the file being treated if it is a physical file
var $currentDataFile = null;
* @var int Number of times newFile function has been called
* @see File_Archive_Writer::File_Archive_Writer()
function File_Archive_Writer_MemoryArchive
($filename, &$t, $stat = array(), $autoClose = true)
$this->memoryWriter = new File_Archive_Writer_Memory($tmp = null);
parent::File_Archive_Writer_Archive($filename, $t, $stat, $autoClose);
* @see File_Archive_Writer::newFile()
function newFile($filename, $stat = array(),
$mime = "application/octet-stream")
if ($this->nbFiles == 0) {
$error = $this->sendHeader();
if (PEAR::isError($error)) {
if (PEAR::isError($error)) {
$this->currentFilename = $filename;
$this->currentStat = $stat;
* @see File_Archive_Writer::close()
if (PEAR::isError($error)) {
$error = $this->sendFooter();
if (PEAR::isError($error)) {
* Indicate that all the data have been read from the current file
* and send it to appendFileData
* Send the current data to the appendFileData function
if ($this->currentFilename !== null) {
if ($this->currentDataFile !== null) {
$error = $this->appendFile($this->currentFilename,
$error = $this->appendFileData($this->currentFilename,
$this->memoryWriter->getData());
if (PEAR::isError($error)) {
$this->currentFilename = null;
$this->currentDataFile = null;
$this->memoryWriter->clear();
* @see File_Archive_Writer::writeData()
function writeData($data) { return $this->memoryWriter->writeData($data); }
* @see File_Archive_Writer::writeFile()
function writeFile($filename)
if ($this->currentDataFile == null && $this->memoryWriter->isEmpty()) {
$this->currentDataFile = $filename;
return $this->memoryWriter->writeFile($filename);
* The subclass must treat the data $data
* $data is the entire data of the filename $filename
* $stat is the stat of the file
function appendFileData($filename, $stat, $data) { }
//SHOULD REWRITE FUNCTIONS
* The subclass may rewrite the sendHeader function if it needs to execute
* code before the first file
function sendHeader() { }
* The subclass may rewrite the sendFooter function if it needs to execute
* code before closing the archive
function sendFooter() { }
* The subclass may rewrite this class if it knows an efficient way to treat
function appendFile($filename, $dataFilename)
return $this->appendFileData(
file_get_contents($dataFilename));
Documentation generated on Mon, 11 Mar 2019 14:21:14 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|