cvs: pear /File_Archive/Archive/Reader Directory.php /File_Archive/Archive/Writer Files.php MemoryArchive.php Zip.php

From: Date: Sun, 29 May 2005 18:08:20 +0000
Subject: cvs: pear /File_Archive/Archive/Reader Directory.php /File_Archive/Archive/Writer Files.php MemoryArchive.php Zip.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-32232@lists.php.net to get a copy of this message
vincentlascaux Sun May 29 14:08:20 2005 EDT Modified files: /pear/File_Archive/Archive/Reader Directory.php /pear/File_Archive/Archive/Writer Files.php MemoryArchive.php Zip.php Log: + DirectoryReader: error message was not set properly when unlink fails + File renaming when writing from temp file was wrong (unlink reports it failed if file doesn't exist) + Simpler MemoryArchive (use a buffer instead of a memory writer) + Pass data by ref rather than copy (don't know if it makes a difference) http://cvs.php.net/diff.php/pear/File_Archive/Archive/Reader/Directory.php?r1=1.18&r2=1.19&ty=u Index: pear/File_Archive/Archive/Reader/Directory.php diff -u pear/File_Archive/Archive/Reader/Directory.php:1.18 pear/File_Archive/Archive/Reader/Directory.php:1.19 --- pear/File_Archive/Archive/Reader/Directory.php:1.18 Sun May 29 08:42:18 2005 +++ pear/File_Archive/Archive/Reader/Directory.php Sun May 29 14:08:20 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.18 2005/05/29 12:42:18 vincentlascaux Exp $ + * @version CVS: $Id: Directory.php,v 1.19 2005/05/29 18:08:20 vincentlascaux Exp $ * @link http://pear.php.net/package/File_Archive */ @@ -150,12 +150,12 @@ while ($this->next()) { if ($toUnlink != null && !@unlink($toUnlink)) { - return PEAR::raiseError($pred); + return PEAR::raiseError("Unable to unlink $toUnlink"); } $toUnlink = ($pred->isTrue($this) ? $this->getDataFilename() : null); } if ($toUnlink != null && - !@unlink($toUnlink)) { + !@unlink("Unable to unlink $toUnlink")) { return PEAR::raiseError($pred); } http://cvs.php.net/diff.php/pear/File_Archive/Archive/Writer/Files.php?r1=1.17&r2=1.18&ty=u Index: pear/File_Archive/Archive/Writer/Files.php diff -u pear/File_Archive/Archive/Writer/Files.php:1.17 pear/File_Archive/Archive/Writer/Files.php:1.18 --- pear/File_Archive/Archive/Writer/Files.php:1.17 Sun May 29 12:00:50 2005 +++ pear/File_Archive/Archive/Writer/Files.php Sun May 29 14:08:20 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: Files.php,v 1.17 2005/05/29 16:00:50 vincentlascaux Exp $ + * @version CVS: $Id: Files.php,v 1.18 2005/05/29 18:08:20 vincentlascaux Exp $ * @link http://pear.php.net/package/File_Archive */ @@ -205,8 +205,11 @@ } } - if (!@unlink($complete) || + echo "New from tmp file: $tmpfile => $complete\n"; + + if ((file_exists($complete) && !@unlink($complete)) || !@rename($tmpfile, $complete)) { + echo "failed to rename\n"; parent::newFromTempFile($tmpfile, $filename, $stat, $mime); } } http://cvs.php.net/diff.php/pear/File_Archive/Archive/Writer/MemoryArchive.php?r1=1.13&r2=1.14&ty=u Index: pear/File_Archive/Archive/Writer/MemoryArchive.php diff -u pear/File_Archive/Archive/Writer/MemoryArchive.php:1.13 pear/File_Archive/Archive/Writer/MemoryArchive.php:1.14 --- pear/File_Archive/Archive/Writer/MemoryArchive.php:1.13 Thu May 26 17:30:18 2005 +++ pear/File_Archive/Archive/Writer/MemoryArchive.php Sun May 29 14:08:20 2005 @@ -26,7 +26,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: MemoryArchive.php,v 1.13 2005/05/26 21:30:18 vincentlascaux Exp $ + * @version CVS: $Id: MemoryArchive.php,v 1.14 2005/05/29 18:08:20 vincentlascaux Exp $ * @link http://pear.php.net/package/File_Archive */ @@ -44,7 +44,7 @@ * waiting for the file to be complete * @access private */ - var $memoryWriter = null; + var $buffer = ''; /** * @var string Name of the file which data are coming * @access private @@ -72,7 +72,6 @@ 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); } @@ -133,7 +132,7 @@ } else { $error = $this->appendFileData($this->currentFilename, $this->currentStat, - $this->memoryWriter->getData()); + $this->buffer); } if (PEAR::isError($error)) { return $error; @@ -141,22 +140,33 @@ $this->currentFilename = null; $this->currentDataFile = null; - $this->memoryWriter->clear(); + $this->buffer = ''; } } /** * @see File_Archive_Writer::writeData() */ - function writeData($data) { return $this->memoryWriter->writeData($data); } + function writeData(&$data) + { + if ($this->currentDataFile !== null) { + $this->buffer .= file_get_contents($this->currentDataFile); + $this->currentDataFile = null; + } + $this->buffer .= $data; + } /** * @see File_Archive_Writer::writeFile() */ function writeFile($filename) { - if ($this->currentDataFile == null && $this->memoryWriter->isEmpty()) { + if ($this->currentDataFile == null && empty($this->buffer)) { $this->currentDataFile = $filename; } else { - return $this->memoryWriter->writeFile($filename); + if ($this->currentDataFile !== null) { + $this->buffer .= file_get_contents($this->currentDataFile); + $this->currentDataFile = null; + } + $this->buffer .= file_get_contents($filename); } } @@ -168,7 +178,7 @@ * * @access protected */ - function appendFileData($filename, $stat, $data) { } + function appendFileData($filename, $stat, &$data) { } //SHOULD REWRITE FUNCTIONS /** http://cvs.php.net/diff.php/pear/File_Archive/Archive/Writer/Zip.php?r1=1.12&r2=1.13&ty=u Index: pear/File_Archive/Archive/Writer/Zip.php diff -u pear/File_Archive/Archive/Writer/Zip.php:1.12 pear/File_Archive/Archive/Writer/Zip.php:1.13 --- pear/File_Archive/Archive/Writer/Zip.php:1.12 Thu May 26 17:30:18 2005 +++ pear/File_Archive/Archive/Writer/Zip.php Sun May 29 14:08:20 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.12 2005/05/26 21:30:18 vincentlascaux Exp $ + * @version CVS: $Id: Zip.php,v 1.13 2005/05/29 18:08:20 vincentlascaux Exp $ * @link http://pear.php.net/package/File_Archive */ @@ -141,7 +141,7 @@ * @see File_Archive_Writer_MemoryArchive::appendFileData() * @access protected */ - function appendFileData($filename, $stat, $data) + function appendFileData($filename, $stat, &$data) { $filename = preg_replace("/^(\.{1,2}(\/|\\\))+/","",$filename);

« previous php.pear.cvs (#32232) next »