cvs: pear /File_Archive Archive.php /File_Archive/Archive/Reader File.php Tar.php Uncompress.php Zip.php /File_Archive/Archive/Writer Files.php
| From: | Vincent Lascaux | Date: | Mon, 30 May 2005 12:54:05 +0000 |
| Subject: | cvs: pear /File_Archive Archive.php /File_Archive/Archive/Reader File.php Tar.php Uncompress.php Zip.php /File_Archive/Archive/Writer Files.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-32242@lists.php.net to get a copy of this message | ||
vincentlascaux Mon May 30 08:54:05 2005 EDT
Modified files:
/pear/File_Archive Archive.php
/pear/File_Archive/Archive/Reader File.php Tar.php Uncompress.php
Zip.php
/pear/File_Archive/Archive/Writer Files.php
Log:
+ Add append and appendToSource functions that appends file to an archive or create the archive if
it doesn't exist
+ Do not look at the MIME type to open a file and remove blocks of data from it (don't know
why I was doing it!)
+ Update the last modification time when adding a file to a nested archive
+ Correct a bug in makeWriter* function on uncompress reader that have been closed (the source is
no longer in base dir in this case)
http://cvs.php.net/diff.php/pear/File_Archive/Archive.php?r1=1.53&r2=1.54&ty=u Index: pear/File_Archive/Archive.php diff -u pear/File_Archive/Archive.php:1.53 pear/File_Archive/Archive.php:1.54 --- pear/File_Archive/Archive.php:1.53 Sun May 29 12:00:49 2005 +++ pear/File_Archive/Archive.php Mon May 30 08:54:05 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: Archive.php,v 1.53 2005/05/29 16:00:49 vincentlascaux Exp $ + * @version CVS: $Id: Archive.php,v 1.54 2005/05/30 12:54:05 vincentlascaux Exp $ * @link http://pear.php.net/package/File_Archive */ @@ -159,6 +159,18 @@ function readSource(&$source, $URL, $symbolic = null, $uncompression = 0, $directoryDepth = -1) { + return File_Archive::_readSource($source, $URL, $reachable, $baseDir, + $symbolic, $uncompression, $directoryDepth); + } + + /** + * This function performs exactly as readSource, but with two additional parameters + * ($reachable and $baseDir) that will be set so that $reachable."/".$baseDir == $URL + * and $reachable can be reached (in case of error) + */ + function _readSource(&$source, $URL, &$reachable, &$baseDir, $symbolic = null, + $uncompression = 0, $directoryDepth = -1) + { if (PEAR::isError($source)) { return $source; } @@ -245,6 +257,7 @@ } $file = substr($realPath, 0, $pos); + $baseDir = substr($realPath, $pos+1); $dotPos = strrpos($file, '.'); $extension = ''; if ($dotPos !== false) { @@ -283,6 +296,7 @@ if (isset($parsedURL['fragment'])) { $file .= '#'.$parsedURL['fragment']; } + $reachable = $file; //If we are reading from the file system if ($source == null) { @@ -882,18 +896,70 @@ /** * Create a writer that allows appending new files to an existing archive + * This function actes as appendToSource with source being the system files + * $URL can't be null here * * @param File_Archive_Reader $source A reader where some files will be appended * @return File_Archive_Writer a writer that you can use to append files to the reader */ - function append(&$source) + function append($URL, $type = null, $stat = array()) { - if (PEAR::isError($source)) { - return $source; + $source = null; + return File_Archive::appendToSource($source, $URL, $type, $stat); + } + + /** + * Create a writer that can be used to append files to an archive inside a source + * If the archive can't be found in the source, it will be created + * If source is set to null, File_Archive::toFiles will be assumed + * If type is set to null, the type of the archive will be determined looking at + * the extension in the URL + * stat is the array of stat (returned by stat() PHP function of Reader getStat()) + * to use if the archive must be created + * + * This function allows to create or append data to nested archives. Only one + * archive will be created and if your creation requires creating several nested + * archives, a PEAR error will be returned + * + * After this call, $source will be closed and should not be used until the + * returned writer is closed. + * + * @param File_Archive_Reader $source A reader where some files will be appended + * @param string $URL URL to reach the archive in the source. + * if $URL is null, a writer to append files to the $source reader will be returned + * @param string $type Extension of the archive (or null to use the one in the URL) + * @param array $stat Used only if archive is created, array of stat as returned by PHP stat function + * or Reader getStat function: stats of the archive) + * Time (index 9) will be overwritten to current time + * @return File_Archive_Writer a writer that you can use to append files to the reader + */ + function appendToSource(&$source, $URL = null, $type = null, $stat = array()) + { + if ($type === null) { + $result = File_Archive::_readSource($source, $URL.'/', $reachable, $baseDir); + } else { + $result = File_Archive::readArchive( + $type, + File_Archive::_readSource($source, $URL, $reachable, $baseDir) + ); + } + if (!PEAR::isError($result)) { + return $result->makeAppendWriter(); + } + + //The source can't be found and has to be created + $stat[9] = $stat['mtime'] = time(); + if (empty($baseDir)) { + return File_Archive::toArchive($reachable, $source, $type); + } else { + return File_Archive::toArchive( + $baseDir, + File_Archive::readSource($source, $reachable), + $type); } - return $source->makeAppendWriter(); } + /** * Remove the files that follow a given predicate from the source * @@ -901,7 +967,7 @@ * @param File_Archive_Predicate $pred The files that follow the predicate * (for which $pred->isTrue($source) is true) will be erased */ - function remove($pred, &$source) + function remove(&$pred, &$source) { if (PEAR::isError($source)) { return $source; @@ -912,6 +978,24 @@ } $writer->close(); } + + /** + * Remove duplicates from a source, keeping the most recent one (or the one that has highest pos in + * the archive if the files have same date or no date specified) + * + * @param File_Archive_Reader a reader that may contain duplicates + */ + function removeDuplicates(&$source) + { + if (PEAR::isError($source)) { + return $source; + } + require_once "File/Archive/Predicate/Duplicate.php"; + return File_Archive::remove( + new File_Archive_Predicate_Duplicate($source), + $source + ); + } } ?> \ No newline at end of file http://cvs.php.net/diff.php/pear/File_Archive/Archive/Reader/File.php?r1=1.21&r2=1.22&ty=u Index: pear/File_Archive/Archive/Reader/File.php diff -u pear/File_Archive/Archive/Reader/File.php:1.21 pear/File_Archive/Archive/Reader/File.php:1.22 --- pear/File_Archive/Archive/Reader/File.php:1.21 Sat May 28 19:17:29 2005 +++ pear/File_Archive/Archive/Reader/File.php Mon May 30 08:54:05 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: File.php,v 1.21 2005/05/28 23:17:29 vincentlascaux Exp $ + * @version CVS: $Id: File.php,v 1.22 2005/05/30 12:54:05 vincentlascaux Exp $ * @link http://pear.php.net/package/File_Archive */ @@ -138,6 +138,7 @@ */ function getMime() { + var_dump(debug_backtrace()); $result = MIME_Type::autoDetect($this->getDataFilename()); if (PEAR::isError($result)) { return parent::getMime(); @@ -218,12 +219,11 @@ if ($this->handle != null) { $file = $this->getDataFilename(); $stat = $this->getStat(); - $mime = $this->getMime(); $pos = ftell($this->handle); $this->close(); - $writer->openFileRemoveBlock($file, $pos + $seek, $blocks, $stat, $mime); + $writer->openFileRemoveBlock($file, $pos + $seek, $blocks, $stat); } return $writer; http://cvs.php.net/diff.php/pear/File_Archive/Archive/Reader/Tar.php?r1=1.26&r2=1.27&ty=u Index: pear/File_Archive/Archive/Reader/Tar.php diff -u pear/File_Archive/Archive/Reader/Tar.php:1.26 pear/File_Archive/Archive/Reader/Tar.php:1.27 --- pear/File_Archive/Archive/Reader/Tar.php:1.26 Sun May 29 12:00:49 2005 +++ pear/File_Archive/Archive/Reader/Tar.php Mon May 30 08:54:05 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.26 2005/05/29 16:00:49 vincentlascaux Exp $ + * @version CVS: $Id: Tar.php,v 1.27 2005/05/30 12:54:05 vincentlascaux Exp $ * @link http://pear.php.net/package/File_Archive */ @@ -312,6 +312,7 @@ } unset($stat[7]); + $stat[9] = $stat['mtime'] = time(); $writer->newFile($filename, $stat); $writer->writeData($data); return $writer; http://cvs.php.net/diff.php/pear/File_Archive/Archive/Reader/Uncompress.php?r1=1.29&r2=1.30&ty=u Index: pear/File_Archive/Archive/Reader/Uncompress.php diff -u pear/File_Archive/Archive/Reader/Uncompress.php:1.29 pear/File_Archive/Archive/Reader/Uncompress.php:1.30 --- pear/File_Archive/Archive/Reader/Uncompress.php:1.29 Sun May 29 08:42:18 2005 +++ pear/File_Archive/Archive/Reader/Uncompress.php Mon May 30 08:54:05 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.29 2005/05/29 12:42:18 vincentlascaux Exp $ + * @version CVS: $Id: Uncompress.php,v 1.30 2005/05/30 12:54:05 vincentlascaux Exp $ * @link http://pear.php.net/package/File_Archive */ @@ -269,6 +269,34 @@ return $error; } + + /** + * @see File_Archive_Reader::makeAppendWriter() + */ + function makeAppendWriter() + { + //The reader needs to be open so that the base dir is found + $error = $this->next(); + if (PEAR::isError($error)) { + return $error; + } + + return parent::makeAppendWriter(); + } + + /** + * @see File_Archive_Reader::makeWriterRemoveFiles() + */ + function makeWriterRemoveFiles($pred) + { + //The reader needs to be open so that the base dir is found + $error = $this->next(); + if (PEAR::isError($error)) { + return $error; + } + + return parent::makeWriterRemoveFiles($pred); + } } ?> \ No newline at end of file http://cvs.php.net/diff.php/pear/File_Archive/Archive/Reader/Zip.php?r1=1.22&r2=1.23&ty=u Index: pear/File_Archive/Archive/Reader/Zip.php diff -u pear/File_Archive/Archive/Reader/Zip.php:1.22 pear/File_Archive/Archive/Reader/Zip.php:1.23 --- pear/File_Archive/Archive/Reader/Zip.php:1.22 Sun May 29 08:42:18 2005 +++ pear/File_Archive/Archive/Reader/Zip.php Mon May 30 08:54:05 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.22 2005/05/29 12:42:18 vincentlascaux Exp $ + * @version CVS: $Id: Zip.php,v 1.23 2005/05/30 12:54:05 vincentlascaux Exp $ * @link http://pear.php.net/package/File_Archive */ @@ -273,7 +273,7 @@ array_pop($this->files); } - while ($this->next()) { + while (($error = $this->next()) === true) { $size = 30 + $this->header['File'] + $this->header['Extra'] + $this->header['CLen']; if ($pred->isTrue($this)) { array_pop($this->files); @@ -296,6 +296,10 @@ } } } + if (PEAR::isError($error)) { + return $error; + } + if ($seek === null) { $seek = 4; } else { @@ -356,6 +360,7 @@ } unset($stat[7]); + $stat[9] = $stat['mtime'] = time(); $writer->newFile($filename, $stat); $writer->writeData($newData); return $writer; http://cvs.php.net/diff.php/pear/File_Archive/Archive/Writer/Files.php?r1=1.18&r2=1.19&ty=u Index: pear/File_Archive/Archive/Writer/Files.php diff -u pear/File_Archive/Archive/Writer/Files.php:1.18 pear/File_Archive/Archive/Writer/Files.php:1.19 --- pear/File_Archive/Archive/Writer/Files.php:1.18 Sun May 29 14:08:20 2005 +++ pear/File_Archive/Archive/Writer/Files.php Mon May 30 08:54:05 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.18 2005/05/29 18:08:20 vincentlascaux Exp $ + * @version CVS: $Id: Files.php,v 1.19 2005/05/30 12:54:05 vincentlascaux Exp $ * @link http://pear.php.net/package/File_Archive */ @@ -98,9 +98,8 @@ * @param string $filename The name of the file to open * @param int $pos the initial position in the file * @param $stat the stats of the file - * @param $mime the mime type of the file */ - function openFile($filename, $pos = 0, $stat = array(), $mime = "application/octet-stream") + function openFile($filename, $pos = 0, $stat = array()) { if ($this->handle !== null) { fclose($this->handle); @@ -123,9 +122,9 @@ * Open a file for appending after having removed a block of data from it * See File_Archive_Reader::makeWriterRemoveBlocks */ - function openFileRemoveBlock($filename, $pos, $blocks, $stat = array(), $mime = "application/octet-stream") + function openFileRemoveBlock($filename, $pos, $blocks, $stat = array()) { - $error = $this->openFile($filename, $pos, $stat, $mime); + $error = $this->openFile($filename, $pos, $stat); if (PEAR::isError($error)) { return $error; } @@ -205,11 +204,8 @@ } } - 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.php?r1=1.53&r2=1.54&ty=u Index: pear/File_Archive/Archive.php diff -u pear/File_Archive/Archive.php:1.53 pear/File_Archive/Archive.php:1.54 --- pear/File_Archive/Archive.php:1.53 Sun May 29 12:00:49 2005 +++ pear/File_Archive/Archive.php Mon May 30 08:54:05 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: Archive.php,v 1.53 2005/05/29 16:00:49 vincentlascaux Exp $ + * @version CVS: $Id: Archive.php,v 1.54 2005/05/30 12:54:05 vincentlascaux Exp $ * @link http://pear.php.net/package/File_Archive */ @@ -159,6 +159,18 @@ function readSource(&$source, $URL, $symbolic = null, $uncompression = 0, $directoryDepth = -1) { + return File_Archive::_readSource($source, $URL, $reachable, $baseDir, + $symbolic, $uncompression, $directoryDepth); + } + + /** + * This function performs exactly as readSource, but with two additional parameters + * ($reachable and $baseDir) that will be set so that $reachable."/".$baseDir == $URL + * and $reachable can be reached (in case of error) + */ + function _readSource(&$source, $URL, &$reachable, &$baseDir, $symbolic = null, + $uncompression = 0, $directoryDepth = -1) + { if (PEAR::isError($source)) { return $source; } @@ -245,6 +257,7 @@ } $file = substr($realPath, 0, $pos); + $baseDir = substr($realPath, $pos+1); $dotPos = strrpos($file, '.'); $extension = ''; if ($dotPos !== false) { @@ -283,6 +296,7 @@ if (isset($parsedURL['fragment'])) { $file .= '#'.$parsedURL['fragment']; } + $reachable = $file; //If we are reading from the file system if ($source == null) { @@ -882,18 +896,70 @@ /** * Create a writer that allows appending new files to an existing archive + * This function actes as appendToSource with source being the system files + * $URL can't be null here * * @param File_Archive_Reader $source A reader where some files will be appended * @return File_Archive_Writer a writer that you can use to append files to the reader */ - function append(&$source) + function append($URL, $type = null, $stat = array()) { - if (PEAR::isError($source)) { - return $source; + $source = null; + return File_Archive::appendToSource($source, $URL, $type, $stat); + } + + /** + * Create a writer that can be used to append files to an archive inside a source + * If the archive can't be found in the source, it will be created + * If source is set to null, File_Archive::toFiles will be assumed + * If type is set to null, the type of the archive will be determined looking at + * the extension in the URL + * stat is the array of stat (returned by stat() PHP function of Reader getStat()) + * to use if the archive must be created + * + * This function allows to create or append data to nested archives. Only one + * archive will be created and if your creation requires creating several nested + * archives, a PEAR error will be returned + * + * After this call, $source will be closed and should not be used until the + * returned writer is closed. + * + * @param File_Archive_Reader $source A reader where some files will be appended + * @param string $URL URL to reach the archive in the source. + * if $URL is null, a writer to append files to the $source reader will be returned + * @param string $type Extension of the archive (or null to use the one in the URL) + * @param array $stat Used only if archive is created, array of stat as returned by PHP stat function + * or Reader getStat function: stats of the archive) + * Time (index 9) will be overwritten to current time + * @return File_Archive_Writer a writer that you can use to append files to the reader + */ + function appendToSource(&$source, $URL = null, $type = null, $stat = array()) + { + if ($type === null) { + $result = File_Archive::_readSource($source, $URL.'/', $reachable, $baseDir); + } else { + $result = File_Archive::readArchive( + $type, + File_Archive::_readSource($source, $URL, $reachable, $baseDir) + ); + } + if (!PEAR::isError($result)) { + return $result->makeAppendWriter(); + } + + //The source can't be found and has to be created + $stat[9] = $stat['mtime'] = time(); + if (empty($baseDir)) { + return File_Archive::toArchive($reachable, $source, $type); + } else { + return File_Archive::toArchive( + $baseDir, + File_Archive::readSource($source, $reachable), + $type); } - return $source->makeAppendWriter(); } + /** * Remove the files that follow a given predicate from the source * @@ -901,7 +967,7 @@ * @param File_Archive_Predicate $pred The files that follow the predicate * (for which $pred->isTrue($source) is true) will be erased */ - function remove($pred, &$source) + function remove(&$pred, &$source) { if (PEAR::isError($source)) { return $source; @@ -912,6 +978,24 @@ } $writer->close(); } + + /** + * Remove duplicates from a source, keeping the most recent one (or the one that has highest pos in + * the archive if the files have same date or no date specified) + * + * @param File_Archive_Reader a reader that may contain duplicates + */ + function removeDuplicates(&$source) + { + if (PEAR::isError($source)) { + return $source; + } + require_once "File/Archive/Predicate/Duplicate.php"; + return File_Archive::remove( + new File_Archive_Predicate_Duplicate($source), + $source + ); + } } ?> \ No newline at end of file http://cvs.php.net/diff.php/pear/File_Archive/Archive/Reader/File.php?r1=1.21&r2=1.22&ty=u Index: pear/File_Archive/Archive/Reader/File.php diff -u pear/File_Archive/Archive/Reader/File.php:1.21 pear/File_Archive/Archive/Reader/File.php:1.22 --- pear/File_Archive/Archive/Reader/File.php:1.21 Sat May 28 19:17:29 2005 +++ pear/File_Archive/Archive/Reader/File.php Mon May 30 08:54:05 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: File.php,v 1.21 2005/05/28 23:17:29 vincentlascaux Exp $ + * @version CVS: $Id: File.php,v 1.22 2005/05/30 12:54:05 vincentlascaux Exp $ * @link http://pear.php.net/package/File_Archive */ @@ -138,6 +138,7 @@ */ function getMime() { + var_dump(debug_backtrace()); $result = MIME_Type::autoDetect($this->getDataFilename()); if (PEAR::isError($result)) { return parent::getMime(); @@ -218,12 +219,11 @@ if ($this->handle != null) { $file = $this->getDataFilename(); $stat = $this->getStat(); - $mime = $this->getMime(); $pos = ftell($this->handle); $this->close(); - $writer->openFileRemoveBlock($file, $pos + $seek, $blocks, $stat, $mime); + $writer->openFileRemoveBlock($file, $pos + $seek, $blocks, $stat); } return $writer; http://cvs.php.net/diff.php/pear/File_Archive/Archive/Reader/Tar.php?r1=1.26&r2=1.27&ty=u Index: pear/File_Archive/Archive/Reader/Tar.php diff -u pear/File_Archive/Archive/Reader/Tar.php:1.26 pear/File_Archive/Archive/Reader/Tar.php:1.27 --- pear/File_Archive/Archive/Reader/Tar.php:1.26 Sun May 29 12:00:49 2005 +++ pear/File_Archive/Archive/Reader/Tar.php Mon May 30 08:54:05 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.26 2005/05/29 16:00:49 vincentlascaux Exp $ + * @version CVS: $Id: Tar.php,v 1.27 2005/05/30 12:54:05 vincentlascaux Exp $ * @link http://pear.php.net/package/File_Archive */ @@ -312,6 +312,7 @@ } unset($stat[7]); + $stat[9] = $stat['mtime'] = time(); $writer->newFile($filename, $stat); $writer->writeData($data); return $writer; http://cvs.php.net/diff.php/pear/File_Archive/Archive/Reader/Uncompress.php?r1=1.29&r2=1.30&ty=u Index: pear/File_Archive/Archive/Reader/Uncompress.php diff -u pear/File_Archive/Archive/Reader/Uncompress.php:1.29 pear/File_Archive/Archive/Reader/Uncompress.php:1.30 --- pear/File_Archive/Archive/Reader/Uncompress.php:1.29 Sun May 29 08:42:18 2005 +++ pear/File_Archive/Archive/Reader/Uncompress.php Mon May 30 08:54:05 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.29 2005/05/29 12:42:18 vincentlascaux Exp $ + * @version CVS: $Id: Uncompress.php,v 1.30 2005/05/30 12:54:05 vincentlascaux Exp $ * @link http://pear.php.net/package/File_Archive */ @@ -269,6 +269,34 @@ return $error; } + + /** + * @see File_Archive_Reader::makeAppendWriter() + */ + function makeAppendWriter() + { + //The reader needs to be open so that the base dir is found + $error = $this->next(); + if (PEAR::isError($error)) { + return $error; + } + + return parent::makeAppendWriter(); + } + + /** + * @see File_Archive_Reader::makeWriterRemoveFiles() + */ + function makeWriterRemoveFiles($pred) + { + //The reader needs to be open so that the base dir is found + $error = $this->next(); + if (PEAR::isError($error)) { + return $error; + } + + return parent::makeWriterRemoveFiles($pred); + } } ?> \ No newline at end of file http://cvs.php.net/diff.php/pear/File_Archive/Archive/Reader/Zip.php?r1=1.22&r2=1.23&ty=u Index: pear/File_Archive/Archive/Reader/Zip.php diff -u pear/File_Archive/Archive/Reader/Zip.php:1.22 pear/File_Archive/Archive/Reader/Zip.php:1.23 --- pear/File_Archive/Archive/Reader/Zip.php:1.22 Sun May 29 08:42:18 2005 +++ pear/File_Archive/Archive/Reader/Zip.php Mon May 30 08:54:05 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.22 2005/05/29 12:42:18 vincentlascaux Exp $ + * @version CVS: $Id: Zip.php,v 1.23 2005/05/30 12:54:05 vincentlascaux Exp $ * @link http://pear.php.net/package/File_Archive */ @@ -273,7 +273,7 @@ array_pop($this->files); } - while ($this->next()) { + while (($error = $this->next()) === true) { $size = 30 + $this->header['File'] + $this->header['Extra'] + $this->header['CLen']; if ($pred->isTrue($this)) { array_pop($this->files); @@ -296,6 +296,10 @@ } } } + if (PEAR::isError($error)) { + return $error; + } + if ($seek === null) { $seek = 4; } else { @@ -356,6 +360,7 @@ } unset($stat[7]); + $stat[9] = $stat['mtime'] = time(); $writer->newFile($filename, $stat); $writer->writeData($newData); return $writer; http://cvs.php.net/diff.php/pear/File_Archive/Archive/Writer/Files.php?r1=1.18&r2=1.19&ty=u Index: pear/File_Archive/Archive/Writer/Files.php diff -u pear/File_Archive/Archive/Writer/Files.php:1.18 pear/File_Archive/Archive/Writer/Files.php:1.19 --- pear/File_Archive/Archive/Writer/Files.php:1.18 Sun May 29 14:08:20 2005 +++ pear/File_Archive/Archive/Writer/Files.php Mon May 30 08:54:05 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.18 2005/05/29 18:08:20 vincentlascaux Exp $ + * @version CVS: $Id: Files.php,v 1.19 2005/05/30 12:54:05 vincentlascaux Exp $ * @link http://pear.php.net/package/File_Archive */ @@ -98,9 +98,8 @@ * @param string $filename The name of the file to open * @param int $pos the initial position in the file * @param $stat the stats of the file - * @param $mime the mime type of the file */ - function openFile($filename, $pos = 0, $stat = array(), $mime = "application/octet-stream") + function openFile($filename, $pos = 0, $stat = array()) { if ($this->handle !== null) { fclose($this->handle); @@ -123,9 +122,9 @@ * Open a file for appending after having removed a block of data from it * See File_Archive_Reader::makeWriterRemoveBlocks */ - function openFileRemoveBlock($filename, $pos, $blocks, $stat = array(), $mime = "application/octet-stream") + function openFileRemoveBlock($filename, $pos, $blocks, $stat = array()) { - $error = $this->openFile($filename, $pos, $stat, $mime); + $error = $this->openFile($filename, $pos, $stat); if (PEAR::isError($error)) { return $error; } @@ -205,11 +204,8 @@ } } - 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); } }