cvs: pear /File_Archive/Archive Reader.php /File_Archive/Archive/Reader Ar.php Bzip2.php Directory.php Gzip.php Memory.php Relay.php Tar.php
Uncompress.php Zip.php
| From: | Vincent Lascaux | Date: | Sun, 29 May 2005 12:42:18 +0000 |
| Subject: | cvs: pear /File_Archive/Archive Reader.php /File_Archive/Archive/Reader Ar.php Bzip2.php Directory.php Gzip.php Memory.php Relay.php Tar.php Uncompress.php Zip.php |
||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-32227@lists.php.net to get a copy of this message | ||
vincentlascaux Sun May 29 08:42:18 2005 EDT
Modified files:
/pear/File_Archive/Archive Reader.php
/pear/File_Archive/Archive/Reader Ar.php Bzip2.php Directory.php
Gzip.php Memory.php Relay.php
Tar.php Uncompress.php Zip.php
Log:
Solve some bugs in uncompress close (one day it will work, maybe)
Doesn't set source to null when makeWriter since $this may be used after (it is only closed)
Correct a bug in Ar makeWriter* functions
http://cvs.php.net/diff.php/pear/File_Archive/Archive/Reader.php?r1=1.27&r2=1.28&ty=u Index: pear/File_Archive/Archive/Reader.php diff -u pear/File_Archive/Archive/Reader.php:1.27 pear/File_Archive/Archive/Reader.php:1.28 --- pear/File_Archive/Archive/Reader.php:1.27 Sat May 28 19:17:29 2005 +++ pear/File_Archive/Archive/Reader.php Sun May 29 08:42:17 2005 @@ -27,7 +27,7 @@ * @author Vincent Lascaux <vincentlascaux@php.net> * @copyright 1997-2005 The PHP Group * @license http://www.gnu.org/copyleft/lesser.html LGPL - * @version CVS: $Id: Reader.php,v 1.27 2005/05/28 23:17:29 vincentlascaux Exp $ + * @version CVS: $Id: Reader.php,v 1.28 2005/05/29 12:42:17 vincentlascaux Exp $ * @link http://pear.php.net/package/File_Archive */ @@ -396,15 +396,6 @@ { return PEAR::raiseError("Reader abstract function call (makeWriterRemoveBlocks)"); } - - /** - * Equivalent to makeWriterRemoveBlocks(array(0)), but may be more efficient - * It creates a writer to append data to a file - */ - function makeWriter() - { - return $this->makeWriterRemoveBlocks(array(0)); - } } ?> \ No newline at end of file http://cvs.php.net/diff.php/pear/File_Archive/Archive/Reader/Ar.php?r1=1.10&r2=1.11&ty=u Index: pear/File_Archive/Archive/Reader/Ar.php diff -u pear/File_Archive/Archive/Reader/Ar.php:1.10 pear/File_Archive/Archive/Reader/Ar.php:1.11 --- pear/File_Archive/Archive/Reader/Ar.php:1.10 Sun May 29 05:30:39 2005 +++ pear/File_Archive/Archive/Reader/Ar.php Sun May 29 08:42:18 2005 @@ -144,6 +144,7 @@ if ($delim == null) { return false; } + // All files inside should have more than 0 bytes of size if ($size < 0) { return PEAR::raiseError("Files must be at least one byte long"); @@ -253,12 +254,12 @@ $seek = null; $gap = 0; if ($this->_currentFilename !== null && $pred->isTrue($this)) { - $seek = $this->_header + $this->currentStat[7] + ($this->_footer ? 1 : 0); + $seek = $this->_header + $this->_currentStat[7] + ($this->_footer ? 1 : 0); $blocks[] = $seek; //Remove this file } while (($error = $this->next()) === true) { - $size = $this->_header + $this->currentStat[7] + ($this->_footer ? 1 : 0); + $size = $this->_header + $this->_currentStat[7] + ($this->_footer ? 1 : 0); if ($pred->isTrue($this)) { if ($seek === null) { $seek = $size; @@ -289,9 +290,11 @@ } } - return new File_Archive_Writer_Tar(null, + $writer = new File_Archive_Writer_Ar(null, $this->source->makeWriterRemoveBlocks($blocks, -$seek) ); + $this->close(); + return $writer; } /** @@ -354,7 +357,7 @@ return $innerWriter; } - $this->source = null; + unset($this->source); $this->close(); return new File_Archive_Writer_Ar(null, $innerWriter); http://cvs.php.net/diff.php/pear/File_Archive/Archive/Reader/Bzip2.php?r1=1.14&r2=1.15&ty=u Index: pear/File_Archive/Archive/Reader/Bzip2.php diff -u pear/File_Archive/Archive/Reader/Bzip2.php:1.14 pear/File_Archive/Archive/Reader/Bzip2.php:1.15 --- pear/File_Archive/Archive/Reader/Bzip2.php:1.14 Sat May 28 19:17:29 2005 +++ pear/File_Archive/Archive/Reader/Bzip2.php Sun May 29 08:42:18 2005 @@ -25,7 +25,7 @@ * @author Vincent Lascaux <vincentlascaux@php.net> * @copyright 1997-2005 The PHP Group * @license http://www.gnu.org/copyleft/lesser.html LGPL - * @version CVS: $Id: Bzip2.php,v 1.14 2005/05/28 23:17:29 vincentlascaux Exp $ + * @version CVS: $Id: Bzip2.php,v 1.15 2005/05/29 12:42:18 vincentlascaux Exp $ * @link http://pear.php.net/package/File_Archive */ @@ -52,6 +52,8 @@ if ($this->tmpName != null) unlink($this->tmpName); + $this->bzfile = null; + $this->tmpName = null; $this->nbRead = 0; $this->filePos = 0; return parent::close($innerClose); @@ -221,7 +223,7 @@ //Create the writer $this->source->rewind(); $innerWriter = $this->source->makeWriterRemoveBlocks(array()); //Truncate the source - $this->source = null; + unset($this->source); $writer = new File_Archive_Writer_Bzip2(null, $innerWriter); //And compress data from the temporary file http://cvs.php.net/diff.php/pear/File_Archive/Archive/Reader/Directory.php?r1=1.17&r2=1.18&ty=u Index: pear/File_Archive/Archive/Reader/Directory.php diff -u pear/File_Archive/Archive/Reader/Directory.php:1.17 pear/File_Archive/Archive/Reader/Directory.php:1.18 --- pear/File_Archive/Archive/Reader/Directory.php:1.17 Sat May 28 20:12:18 2005 +++ pear/File_Archive/Archive/Reader/Directory.php Sun May 29 08:42:18 2005 @@ -25,7 +25,7 @@ * @author Vincent Lascaux <vincentlascaux@php.net> * @copyright 1997-2005 The PHP Group * @license http://www.gnu.org/copyleft/lesser.html LGPL - * @version CVS: $Id: Directory.php,v 1.17 2005/05/29 00:12:18 vincentlascaux Exp $ + * @version CVS: $Id: Directory.php,v 1.18 2005/05/29 12:42:18 vincentlascaux Exp $ * @link http://pear.php.net/package/File_Archive */ @@ -77,8 +77,10 @@ { $error = parent::close(); - closedir($this->directoryHandle); - $this->directoryHandle = null; + if ($this->directoryHandle !== null) { + closedir($this->directoryHandle); + $this->directoryHandle = null; + } return $error; } @@ -164,13 +166,13 @@ return $writer; } - function getLastSource() + function &getLastSource() { if ($this->source === null || is_a($this->source, 'File_Archive_Reader_File')) { - return &$this->source; + return $this->source; } else { - return &$this->source->getLastSource(); + return $this->source->getLastSource(); } } http://cvs.php.net/diff.php/pear/File_Archive/Archive/Reader/Gzip.php?r1=1.23&r2=1.24&ty=u Index: pear/File_Archive/Archive/Reader/Gzip.php diff -u pear/File_Archive/Archive/Reader/Gzip.php:1.23 pear/File_Archive/Archive/Reader/Gzip.php:1.24 --- pear/File_Archive/Archive/Reader/Gzip.php:1.23 Sat May 28 19:17:29 2005 +++ pear/File_Archive/Archive/Reader/Gzip.php Sun May 29 08:42:18 2005 @@ -25,7 +25,7 @@ * @author Vincent Lascaux <vincentlascaux@php.net> * @copyright 1997-2005 The PHP Group * @license http://www.gnu.org/copyleft/lesser.html LGPL - * @version CVS: $Id: Gzip.php,v 1.23 2005/05/28 23:17:29 vincentlascaux Exp $ + * @version CVS: $Id: Gzip.php,v 1.24 2005/05/29 12:42:18 vincentlascaux Exp $ * @link http://pear.php.net/package/File_Archive */ @@ -247,7 +247,7 @@ //Create the writer $this->source->rewind(); $innerWriter = $this->source->makeWriterRemoveBlocks(array()); //Truncate the source - $this->source = null; + unset($this->source); $writer = new File_Archive_Writer_Gzip(null, $innerWriter); //And compress data from the temporary file http://cvs.php.net/diff.php/pear/File_Archive/Archive/Reader/Memory.php?r1=1.17&r2=1.18&ty=u Index: pear/File_Archive/Archive/Reader/Memory.php diff -u pear/File_Archive/Archive/Reader/Memory.php:1.17 pear/File_Archive/Archive/Reader/Memory.php:1.18 --- pear/File_Archive/Archive/Reader/Memory.php:1.17 Sat May 28 19:17:29 2005 +++ pear/File_Archive/Archive/Reader/Memory.php Sun May 29 08:42:18 2005 @@ -25,7 +25,7 @@ * @author Vincent Lascaux <vincentlascaux@php.net> * @copyright 1997-2005 The PHP Group * @license http://www.gnu.org/copyleft/lesser.html LGPL - * @version CVS: $Id: Memory.php,v 1.17 2005/05/28 23:17:29 vincentlascaux Exp $ + * @version CVS: $Id: Memory.php,v 1.18 2005/05/29 12:42:18 vincentlascaux Exp $ * @link http://pear.php.net/package/File_Archive */ @@ -207,10 +207,11 @@ $keep = !$keep; } if ($keep) { - $this->memory = data . $this->memory; + $this->memory = $data . $this->memory; } else { - $this->memory = data; + $this->memory = $data; } + $this->close(); return new File_Archive_Writer_Memory($this->memory, strlen($this->memory)); } } http://cvs.php.net/diff.php/pear/File_Archive/Archive/Reader/Relay.php?r1=1.15&r2=1.16&ty=u Index: pear/File_Archive/Archive/Reader/Relay.php diff -u pear/File_Archive/Archive/Reader/Relay.php:1.15 pear/File_Archive/Archive/Reader/Relay.php:1.16 --- pear/File_Archive/Archive/Reader/Relay.php:1.15 Sat May 28 19:17:29 2005 +++ pear/File_Archive/Archive/Reader/Relay.php Sun May 29 08:42:18 2005 @@ -25,7 +25,7 @@ * @author Vincent Lascaux <vincentlascaux@php.net> * @copyright 1997-2005 The PHP Group * @license http://www.gnu.org/copyleft/lesser.html LGPL - * @version CVS: $Id: Relay.php,v 1.15 2005/05/28 23:17:29 vincentlascaux Exp $ + * @version CVS: $Id: Relay.php,v 1.16 2005/05/29 12:42:18 vincentlascaux Exp $ * @link http://pear.php.net/package/File_Archive */ @@ -94,25 +94,36 @@ /** * @see File_Archive_Reader::makeAppendWriter() */ - function makeAppendWriter() { return $this->source->makeAppendWriter(); } + function makeAppendWriter() + { + $writer = $this->source->makeAppendWriter(); + if (!PEAR::isError($writer)) { + $this->close(); + } + return $writer; + } /** * @see File_Archive_Reader::makeWriterRemoveFiles() */ function makeWriterRemoveFiles($pred) { - return $this->source->makeWriterRemoveFiles($pred); + $writer = $this->source->makeWriterRemoveFiles($pred); + if (!PEAR::isError($writer)) { + $this->close(); + } + return $writer; } /** * @see File_Archive_Reader::makeWriterRemoveBlocks() */ function makeWriterRemoveBlocks($blocks, $seek = 0) { - return $this->source->makeWriterRemoveBlocks($blocks, $seek); + $writer = $this->source->makeWriterRemoveBlocks($blocks, $seek); + if (!PEAR::isError($writer)) { + $this->close(); + } + return $writer; } - /** - * @see File_Archive_Reader::makeWriter() - */ - function makeWriter() { return $this->source->makeWriter(); } } ?> \ No newline at end of file http://cvs.php.net/diff.php/pear/File_Archive/Archive/Reader/Tar.php?r1=1.24&r2=1.25&ty=u Index: pear/File_Archive/Archive/Reader/Tar.php diff -u pear/File_Archive/Archive/Reader/Tar.php:1.24 pear/File_Archive/Archive/Reader/Tar.php:1.25 --- pear/File_Archive/Archive/Reader/Tar.php:1.24 Sun May 29 05:30:39 2005 +++ pear/File_Archive/Archive/Reader/Tar.php Sun May 29 08:42:18 2005 @@ -25,7 +25,7 @@ * @author Vincent Lascaux <vincentlascaux@php.net> * @copyright 1997-2005 The PHP Group * @license http://www.gnu.org/copyleft/lesser.html LGPL - * @version CVS: $Id: Tar.php,v 1.24 2005/05/29 09:30:39 vincentlascaux Exp $ + * @version CVS: $Id: Tar.php,v 1.25 2005/05/29 12:42:18 vincentlascaux Exp $ * @link http://pear.php.net/package/File_Archive */ @@ -103,13 +103,13 @@ /** * @see File_Archive_Reader::close() */ - function close($innerClose = true) + function close() { $this->leftLength = 0; $this->currentFilename = null; $this->currentStat = null; $this->seekToEnd = null; - return parent::close($innerClose); + return parent::close(); } /** @@ -269,9 +269,11 @@ } } - return new File_Archive_Writer_Tar(null, + $writer = new File_Archive_Writer_Tar(null, $this->source->makeWriterRemoveBlocks($blocks, -$seek) ); + $this->close(); + return $writer; } /** @@ -334,7 +336,6 @@ return $innerWriter; } - $this->source = null; $this->close(); return new File_Archive_Writer_Tar(null, $innerWriter); } http://cvs.php.net/diff.php/pear/File_Archive/Archive/Reader/Uncompress.php?r1=1.28&r2=1.29&ty=u Index: pear/File_Archive/Archive/Reader/Uncompress.php diff -u pear/File_Archive/Archive/Reader/Uncompress.php:1.28 pear/File_Archive/Archive/Reader/Uncompress.php:1.29 --- pear/File_Archive/Archive/Reader/Uncompress.php:1.28 Thu May 26 17:30:18 2005 +++ pear/File_Archive/Archive/Reader/Uncompress.php Sun May 29 08:42:18 2005 @@ -25,7 +25,7 @@ * @author Vincent Lascaux <vincentlascaux@php.net> * @copyright 1997-2005 The PHP Group * @license http://www.gnu.org/copyleft/lesser.html LGPL - * @version CVS: $Id: Uncompress.php,v 1.28 2005/05/26 21:30:18 vincentlascaux Exp $ + * @version CVS: $Id: Uncompress.php,v 1.29 2005/05/29 12:42:18 vincentlascaux Exp $ * @link http://pear.php.net/package/File_Archive */ @@ -44,6 +44,12 @@ var $readers = array(); /** + * @var array of readers to close when closing $this + * @access private + */ + var $toClose = array(); + + /** * @var File_Archive_Reader Reader from which all started (usefull to be * able to close) * @access private @@ -179,6 +185,8 @@ if ($this->baseDirCompressionLevel === null && strlen($currentFilename) >= strlen($this->baseDir)) { $this->baseDirCompressionLevel = count($this->readers); + $this->toClose = $this->readers; + $this->readers = array(); } } while ($this->push()); return true; @@ -190,7 +198,7 @@ */ function setBaseDir($baseDir) { - $this->baseDirUncompressionLevel = null; + $this->baseDirCompressionLevel = null; $this->baseDir = $baseDir; $error = $this->next(); @@ -199,7 +207,6 @@ } else if (PEAR::isError($error)) { return $error; } - $this->readers = array(); $this->currentFileNotDisplayed = true; return strlen($this->getFilename())>strlen($baseDir); @@ -243,10 +250,19 @@ for ($i=0; $i<count($this->readers); ++$i) { $this->readers[$i]->close(); } + //var_dump($this->toClose); + for ($i=0; $i<count($this->toClose); ++$i) { + if ($this->toClose[$i] !== null) { + $this->toClose[$i]->close(); + } + } $this->readers = array(); + $this->toClose = array(); $error = parent::close(); + $this->baseDirCompressionLevel = null; + unset($this->source); $this->source =& $this->startReader; $this->source->close(); $this->currentFileNotDisplayed = false; http://cvs.php.net/diff.php/pear/File_Archive/Archive/Reader/Zip.php?r1=1.21&r2=1.22&ty=u Index: pear/File_Archive/Archive/Reader/Zip.php diff -u pear/File_Archive/Archive/Reader/Zip.php:1.21 pear/File_Archive/Archive/Reader/Zip.php:1.22 --- pear/File_Archive/Archive/Reader/Zip.php:1.21 Sat May 28 19:17:29 2005 +++ pear/File_Archive/Archive/Reader/Zip.php Sun May 29 08:42:18 2005 @@ -25,7 +25,7 @@ * @author Vincent Lascaux <vincentlascaux@php.net> * @copyright 1997-2005 The PHP Group * @license http://www.gnu.org/copyleft/lesser.html LGPL - * @version CVS: $Id: Zip.php,v 1.21 2005/05/28 23:17:29 vincentlascaux Exp $ + * @version CVS: $Id: Zip.php,v 1.22 2005/05/29 12:42:18 vincentlascaux Exp $ * @link http://pear.php.net/package/File_Archive */ @@ -318,7 +318,6 @@ $writer->alreadyWrittenFile($file['name'], $file['stat'], $file['CRC'], $file['CLen']); } - $this->source = null; $this->close(); return $writer; } @@ -383,7 +382,6 @@ $writer->alreadyWrittenFile($file['name'], $file['stat'], $file['CRC'], $file['CLen']); } - $this->source = null; $this->close(); return $writer; }
http://cvs.php.net/diff.php/pear/File_Archive/Archive/Reader.php?r1=1.27&r2=1.28&ty=u Index: pear/File_Archive/Archive/Reader.php diff -u pear/File_Archive/Archive/Reader.php:1.27 pear/File_Archive/Archive/Reader.php:1.28 --- pear/File_Archive/Archive/Reader.php:1.27 Sat May 28 19:17:29 2005 +++ pear/File_Archive/Archive/Reader.php Sun May 29 08:42:17 2005 @@ -27,7 +27,7 @@ * @author Vincent Lascaux <vincentlascaux@php.net> * @copyright 1997-2005 The PHP Group * @license http://www.gnu.org/copyleft/lesser.html LGPL - * @version CVS: $Id: Reader.php,v 1.27 2005/05/28 23:17:29 vincentlascaux Exp $ + * @version CVS: $Id: Reader.php,v 1.28 2005/05/29 12:42:17 vincentlascaux Exp $ * @link http://pear.php.net/package/File_Archive */ @@ -396,15 +396,6 @@ { return PEAR::raiseError("Reader abstract function call (makeWriterRemoveBlocks)"); } - - /** - * Equivalent to makeWriterRemoveBlocks(array(0)), but may be more efficient - * It creates a writer to append data to a file - */ - function makeWriter() - { - return $this->makeWriterRemoveBlocks(array(0)); - } } ?> \ No newline at end of file http://cvs.php.net/diff.php/pear/File_Archive/Archive/Reader/Ar.php?r1=1.10&r2=1.11&ty=u Index: pear/File_Archive/Archive/Reader/Ar.php diff -u pear/File_Archive/Archive/Reader/Ar.php:1.10 pear/File_Archive/Archive/Reader/Ar.php:1.11 --- pear/File_Archive/Archive/Reader/Ar.php:1.10 Sun May 29 05:30:39 2005 +++ pear/File_Archive/Archive/Reader/Ar.php Sun May 29 08:42:18 2005 @@ -144,6 +144,7 @@ if ($delim == null) { return false; } + // All files inside should have more than 0 bytes of size if ($size < 0) { return PEAR::raiseError("Files must be at least one byte long"); @@ -253,12 +254,12 @@ $seek = null; $gap = 0; if ($this->_currentFilename !== null && $pred->isTrue($this)) { - $seek = $this->_header + $this->currentStat[7] + ($this->_footer ? 1 : 0); + $seek = $this->_header + $this->_currentStat[7] + ($this->_footer ? 1 : 0); $blocks[] = $seek; //Remove this file } while (($error = $this->next()) === true) { - $size = $this->_header + $this->currentStat[7] + ($this->_footer ? 1 : 0); + $size = $this->_header + $this->_currentStat[7] + ($this->_footer ? 1 : 0); if ($pred->isTrue($this)) { if ($seek === null) { $seek = $size; @@ -289,9 +290,11 @@ } } - return new File_Archive_Writer_Tar(null, + $writer = new File_Archive_Writer_Ar(null, $this->source->makeWriterRemoveBlocks($blocks, -$seek) ); + $this->close(); + return $writer; } /** @@ -354,7 +357,7 @@ return $innerWriter; } - $this->source = null; + unset($this->source); $this->close(); return new File_Archive_Writer_Ar(null, $innerWriter); http://cvs.php.net/diff.php/pear/File_Archive/Archive/Reader/Bzip2.php?r1=1.14&r2=1.15&ty=u Index: pear/File_Archive/Archive/Reader/Bzip2.php diff -u pear/File_Archive/Archive/Reader/Bzip2.php:1.14 pear/File_Archive/Archive/Reader/Bzip2.php:1.15 --- pear/File_Archive/Archive/Reader/Bzip2.php:1.14 Sat May 28 19:17:29 2005 +++ pear/File_Archive/Archive/Reader/Bzip2.php Sun May 29 08:42:18 2005 @@ -25,7 +25,7 @@ * @author Vincent Lascaux <vincentlascaux@php.net> * @copyright 1997-2005 The PHP Group * @license http://www.gnu.org/copyleft/lesser.html LGPL - * @version CVS: $Id: Bzip2.php,v 1.14 2005/05/28 23:17:29 vincentlascaux Exp $ + * @version CVS: $Id: Bzip2.php,v 1.15 2005/05/29 12:42:18 vincentlascaux Exp $ * @link http://pear.php.net/package/File_Archive */ @@ -52,6 +52,8 @@ if ($this->tmpName != null) unlink($this->tmpName); + $this->bzfile = null; + $this->tmpName = null; $this->nbRead = 0; $this->filePos = 0; return parent::close($innerClose); @@ -221,7 +223,7 @@ //Create the writer $this->source->rewind(); $innerWriter = $this->source->makeWriterRemoveBlocks(array()); //Truncate the source - $this->source = null; + unset($this->source); $writer = new File_Archive_Writer_Bzip2(null, $innerWriter); //And compress data from the temporary file http://cvs.php.net/diff.php/pear/File_Archive/Archive/Reader/Directory.php?r1=1.17&r2=1.18&ty=u Index: pear/File_Archive/Archive/Reader/Directory.php diff -u pear/File_Archive/Archive/Reader/Directory.php:1.17 pear/File_Archive/Archive/Reader/Directory.php:1.18 --- pear/File_Archive/Archive/Reader/Directory.php:1.17 Sat May 28 20:12:18 2005 +++ pear/File_Archive/Archive/Reader/Directory.php Sun May 29 08:42:18 2005 @@ -25,7 +25,7 @@ * @author Vincent Lascaux <vincentlascaux@php.net> * @copyright 1997-2005 The PHP Group * @license http://www.gnu.org/copyleft/lesser.html LGPL - * @version CVS: $Id: Directory.php,v 1.17 2005/05/29 00:12:18 vincentlascaux Exp $ + * @version CVS: $Id: Directory.php,v 1.18 2005/05/29 12:42:18 vincentlascaux Exp $ * @link http://pear.php.net/package/File_Archive */ @@ -77,8 +77,10 @@ { $error = parent::close(); - closedir($this->directoryHandle); - $this->directoryHandle = null; + if ($this->directoryHandle !== null) { + closedir($this->directoryHandle); + $this->directoryHandle = null; + } return $error; } @@ -164,13 +166,13 @@ return $writer; } - function getLastSource() + function &getLastSource() { if ($this->source === null || is_a($this->source, 'File_Archive_Reader_File')) { - return &$this->source; + return $this->source; } else { - return &$this->source->getLastSource(); + return $this->source->getLastSource(); } } http://cvs.php.net/diff.php/pear/File_Archive/Archive/Reader/Gzip.php?r1=1.23&r2=1.24&ty=u Index: pear/File_Archive/Archive/Reader/Gzip.php diff -u pear/File_Archive/Archive/Reader/Gzip.php:1.23 pear/File_Archive/Archive/Reader/Gzip.php:1.24 --- pear/File_Archive/Archive/Reader/Gzip.php:1.23 Sat May 28 19:17:29 2005 +++ pear/File_Archive/Archive/Reader/Gzip.php Sun May 29 08:42:18 2005 @@ -25,7 +25,7 @@ * @author Vincent Lascaux <vincentlascaux@php.net> * @copyright 1997-2005 The PHP Group * @license http://www.gnu.org/copyleft/lesser.html LGPL - * @version CVS: $Id: Gzip.php,v 1.23 2005/05/28 23:17:29 vincentlascaux Exp $ + * @version CVS: $Id: Gzip.php,v 1.24 2005/05/29 12:42:18 vincentlascaux Exp $ * @link http://pear.php.net/package/File_Archive */ @@ -247,7 +247,7 @@ //Create the writer $this->source->rewind(); $innerWriter = $this->source->makeWriterRemoveBlocks(array()); //Truncate the source - $this->source = null; + unset($this->source); $writer = new File_Archive_Writer_Gzip(null, $innerWriter); //And compress data from the temporary file http://cvs.php.net/diff.php/pear/File_Archive/Archive/Reader/Memory.php?r1=1.17&r2=1.18&ty=u Index: pear/File_Archive/Archive/Reader/Memory.php diff -u pear/File_Archive/Archive/Reader/Memory.php:1.17 pear/File_Archive/Archive/Reader/Memory.php:1.18 --- pear/File_Archive/Archive/Reader/Memory.php:1.17 Sat May 28 19:17:29 2005 +++ pear/File_Archive/Archive/Reader/Memory.php Sun May 29 08:42:18 2005 @@ -25,7 +25,7 @@ * @author Vincent Lascaux <vincentlascaux@php.net> * @copyright 1997-2005 The PHP Group * @license http://www.gnu.org/copyleft/lesser.html LGPL - * @version CVS: $Id: Memory.php,v 1.17 2005/05/28 23:17:29 vincentlascaux Exp $ + * @version CVS: $Id: Memory.php,v 1.18 2005/05/29 12:42:18 vincentlascaux Exp $ * @link http://pear.php.net/package/File_Archive */ @@ -207,10 +207,11 @@ $keep = !$keep; } if ($keep) { - $this->memory = data . $this->memory; + $this->memory = $data . $this->memory; } else { - $this->memory = data; + $this->memory = $data; } + $this->close(); return new File_Archive_Writer_Memory($this->memory, strlen($this->memory)); } } http://cvs.php.net/diff.php/pear/File_Archive/Archive/Reader/Relay.php?r1=1.15&r2=1.16&ty=u Index: pear/File_Archive/Archive/Reader/Relay.php diff -u pear/File_Archive/Archive/Reader/Relay.php:1.15 pear/File_Archive/Archive/Reader/Relay.php:1.16 --- pear/File_Archive/Archive/Reader/Relay.php:1.15 Sat May 28 19:17:29 2005 +++ pear/File_Archive/Archive/Reader/Relay.php Sun May 29 08:42:18 2005 @@ -25,7 +25,7 @@ * @author Vincent Lascaux <vincentlascaux@php.net> * @copyright 1997-2005 The PHP Group * @license http://www.gnu.org/copyleft/lesser.html LGPL - * @version CVS: $Id: Relay.php,v 1.15 2005/05/28 23:17:29 vincentlascaux Exp $ + * @version CVS: $Id: Relay.php,v 1.16 2005/05/29 12:42:18 vincentlascaux Exp $ * @link http://pear.php.net/package/File_Archive */ @@ -94,25 +94,36 @@ /** * @see File_Archive_Reader::makeAppendWriter() */ - function makeAppendWriter() { return $this->source->makeAppendWriter(); } + function makeAppendWriter() + { + $writer = $this->source->makeAppendWriter(); + if (!PEAR::isError($writer)) { + $this->close(); + } + return $writer; + } /** * @see File_Archive_Reader::makeWriterRemoveFiles() */ function makeWriterRemoveFiles($pred) { - return $this->source->makeWriterRemoveFiles($pred); + $writer = $this->source->makeWriterRemoveFiles($pred); + if (!PEAR::isError($writer)) { + $this->close(); + } + return $writer; } /** * @see File_Archive_Reader::makeWriterRemoveBlocks() */ function makeWriterRemoveBlocks($blocks, $seek = 0) { - return $this->source->makeWriterRemoveBlocks($blocks, $seek); + $writer = $this->source->makeWriterRemoveBlocks($blocks, $seek); + if (!PEAR::isError($writer)) { + $this->close(); + } + return $writer; } - /** - * @see File_Archive_Reader::makeWriter() - */ - function makeWriter() { return $this->source->makeWriter(); } } ?> \ No newline at end of file http://cvs.php.net/diff.php/pear/File_Archive/Archive/Reader/Tar.php?r1=1.24&r2=1.25&ty=u Index: pear/File_Archive/Archive/Reader/Tar.php diff -u pear/File_Archive/Archive/Reader/Tar.php:1.24 pear/File_Archive/Archive/Reader/Tar.php:1.25 --- pear/File_Archive/Archive/Reader/Tar.php:1.24 Sun May 29 05:30:39 2005 +++ pear/File_Archive/Archive/Reader/Tar.php Sun May 29 08:42:18 2005 @@ -25,7 +25,7 @@ * @author Vincent Lascaux <vincentlascaux@php.net> * @copyright 1997-2005 The PHP Group * @license http://www.gnu.org/copyleft/lesser.html LGPL - * @version CVS: $Id: Tar.php,v 1.24 2005/05/29 09:30:39 vincentlascaux Exp $ + * @version CVS: $Id: Tar.php,v 1.25 2005/05/29 12:42:18 vincentlascaux Exp $ * @link http://pear.php.net/package/File_Archive */ @@ -103,13 +103,13 @@ /** * @see File_Archive_Reader::close() */ - function close($innerClose = true) + function close() { $this->leftLength = 0; $this->currentFilename = null; $this->currentStat = null; $this->seekToEnd = null; - return parent::close($innerClose); + return parent::close(); } /** @@ -269,9 +269,11 @@ } } - return new File_Archive_Writer_Tar(null, + $writer = new File_Archive_Writer_Tar(null, $this->source->makeWriterRemoveBlocks($blocks, -$seek) ); + $this->close(); + return $writer; } /** @@ -334,7 +336,6 @@ return $innerWriter; } - $this->source = null; $this->close(); return new File_Archive_Writer_Tar(null, $innerWriter); } http://cvs.php.net/diff.php/pear/File_Archive/Archive/Reader/Uncompress.php?r1=1.28&r2=1.29&ty=u Index: pear/File_Archive/Archive/Reader/Uncompress.php diff -u pear/File_Archive/Archive/Reader/Uncompress.php:1.28 pear/File_Archive/Archive/Reader/Uncompress.php:1.29 --- pear/File_Archive/Archive/Reader/Uncompress.php:1.28 Thu May 26 17:30:18 2005 +++ pear/File_Archive/Archive/Reader/Uncompress.php Sun May 29 08:42:18 2005 @@ -25,7 +25,7 @@ * @author Vincent Lascaux <vincentlascaux@php.net> * @copyright 1997-2005 The PHP Group * @license http://www.gnu.org/copyleft/lesser.html LGPL - * @version CVS: $Id: Uncompress.php,v 1.28 2005/05/26 21:30:18 vincentlascaux Exp $ + * @version CVS: $Id: Uncompress.php,v 1.29 2005/05/29 12:42:18 vincentlascaux Exp $ * @link http://pear.php.net/package/File_Archive */ @@ -44,6 +44,12 @@ var $readers = array(); /** + * @var array of readers to close when closing $this + * @access private + */ + var $toClose = array(); + + /** * @var File_Archive_Reader Reader from which all started (usefull to be * able to close) * @access private @@ -179,6 +185,8 @@ if ($this->baseDirCompressionLevel === null && strlen($currentFilename) >= strlen($this->baseDir)) { $this->baseDirCompressionLevel = count($this->readers); + $this->toClose = $this->readers; + $this->readers = array(); } } while ($this->push()); return true; @@ -190,7 +198,7 @@ */ function setBaseDir($baseDir) { - $this->baseDirUncompressionLevel = null; + $this->baseDirCompressionLevel = null; $this->baseDir = $baseDir; $error = $this->next(); @@ -199,7 +207,6 @@ } else if (PEAR::isError($error)) { return $error; } - $this->readers = array(); $this->currentFileNotDisplayed = true; return strlen($this->getFilename())>strlen($baseDir); @@ -243,10 +250,19 @@ for ($i=0; $i<count($this->readers); ++$i) { $this->readers[$i]->close(); } + //var_dump($this->toClose); + for ($i=0; $i<count($this->toClose); ++$i) { + if ($this->toClose[$i] !== null) { + $this->toClose[$i]->close(); + } + } $this->readers = array(); + $this->toClose = array(); $error = parent::close(); + $this->baseDirCompressionLevel = null; + unset($this->source); $this->source =& $this->startReader; $this->source->close(); $this->currentFileNotDisplayed = false; http://cvs.php.net/diff.php/pear/File_Archive/Archive/Reader/Zip.php?r1=1.21&r2=1.22&ty=u Index: pear/File_Archive/Archive/Reader/Zip.php diff -u pear/File_Archive/Archive/Reader/Zip.php:1.21 pear/File_Archive/Archive/Reader/Zip.php:1.22 --- pear/File_Archive/Archive/Reader/Zip.php:1.21 Sat May 28 19:17:29 2005 +++ pear/File_Archive/Archive/Reader/Zip.php Sun May 29 08:42:18 2005 @@ -25,7 +25,7 @@ * @author Vincent Lascaux <vincentlascaux@php.net> * @copyright 1997-2005 The PHP Group * @license http://www.gnu.org/copyleft/lesser.html LGPL - * @version CVS: $Id: Zip.php,v 1.21 2005/05/28 23:17:29 vincentlascaux Exp $ + * @version CVS: $Id: Zip.php,v 1.22 2005/05/29 12:42:18 vincentlascaux Exp $ * @link http://pear.php.net/package/File_Archive */ @@ -318,7 +318,6 @@ $writer->alreadyWrittenFile($file['name'], $file['stat'], $file['CRC'], $file['CLen']); } - $this->source = null; $this->close(); return $writer; } @@ -383,7 +382,6 @@ $writer->alreadyWrittenFile($file['name'], $file['stat'], $file['CRC'], $file['CLen']); } - $this->source = null; $this->close(); return $writer; }