cvs: pear /File_Archive/Archive/Reader Concat.php File.php Memory.php Tar.php Zip.php
| From: | Vincent Lascaux | Date: | Sat, 21 May 2005 22:25:23 +0000 |
| Subject: | cvs: pear /File_Archive/Archive/Reader Concat.php File.php Memory.php Tar.php Zip.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-32001@lists.php.net to get a copy of this message | ||
vincentlascaux Sat May 21 18:25:23 2005 EDT
Modified files:
/pear/File_Archive/Archive/Reader Concat.php File.php Memory.php
Tar.php Zip.php
Log:
Stats have now both numeric and string index (7 and 'size' for example), like the PHP
stat function has
http://cvs.php.net/diff.php/pear/File_Archive/Archive/Reader/Concat.php?r1=1.8&r2=1.9&ty=u Index: pear/File_Archive/Archive/Reader/Concat.php diff -u pear/File_Archive/Archive/Reader/Concat.php:1.8 pear/File_Archive/Archive/Reader/Concat.php:1.9 --- pear/File_Archive/Archive/Reader/Concat.php:1.8 Wed May 4 09:53:40 2005 +++ pear/File_Archive/Archive/Reader/Concat.php Sat May 21 18:25:23 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: Concat.php,v 1.8 2005/05/04 13:53:40 vincentlascaux Exp $ + * @version CVS: $Id: Concat.php,v 1.9 2005/05/21 22:25:23 vincentlascaux Exp $ * @link http://pear.php.net/package/File_Archive */ @@ -55,7 +55,15 @@ $this->stat[7] = 0; while (($error = $source->next()) === true) { $sourceStat = $source->getStat(); - $this->stat[7] += $sourceStat[7]; + if (isset($sourceStat[7])) { + $this->stat[7] += $sourceStat[7]; + } else { + unset($this->stat[7]); + break; + } + } + if (isset($this->stat[7])) { + $this->stat['size'] = $this->stat[7]; } if (PEAR::isError($error) || PEAR::isError($source->close())) { die("Error in File_Archive_Reader_Concat constructor ". http://cvs.php.net/diff.php/pear/File_Archive/Archive/Reader/File.php?r1=1.15&r2=1.16&ty=u Index: pear/File_Archive/Archive/Reader/File.php diff -u pear/File_Archive/Archive/Reader/File.php:1.15 pear/File_Archive/Archive/Reader/File.php:1.16 --- pear/File_Archive/Archive/Reader/File.php:1.15 Fri May 13 19:32:25 2005 +++ pear/File_Archive/Archive/Reader/File.php Sat May 21 18:25:23 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.15 2005/05/13 23:32:25 vincentlascaux Exp $ + * @version CVS: $Id: File.php,v 1.16 2005/05/21 22:25:23 vincentlascaux Exp $ * @link http://pear.php.net/package/File_Archive */ @@ -58,13 +58,6 @@ * @access private */ var $stat = null; - /** - * @var File_Archive_Reader_Memory If we can't use stat on the URL, we need - * to read the whole file to compute its length. In this case $memory - * won't be null, and store the content of the file - * @access private - */ - var $memory = null; /** * $filename is the physical file to read @@ -108,7 +101,6 @@ if (!is_resource($this->handle)) { return PEAR::raiseError("Can't open {$this->filename} for reading"); } - $this->memory = null; if ($this->handle === false) { return PEAR::raiseError("File {$this->filename} not found"); } else { @@ -135,16 +127,7 @@ //If we can't use the stat function if ($this->stat === false) { - $alreadyRead = ftell($this->handle); - - //Put the whole file content in memory - require_once "Memory.php"; - $this->memory = new File_Archive_Reader_Memory( - $this->getData(), - $this->symbolic); - - $this->stat = $this->memory->getStat(); - $this->stat = array(7 => $this->stat[7] + $alreadyRead); + $this->stat = array(); } } return $this->stat; @@ -168,10 +151,6 @@ */ function getData($length = -1) { - if ($this->memory != null) { - return $this->memory->getData($length); - } - if (feof($this->handle)) { return null; } @@ -194,10 +173,6 @@ */ function skip($length) { - if ($this->memory != null) { - return $this->memory->skip($length); - } - $before = ftell($this->handle); if (@fseek($this->handle, $length, SEEK_CUR) === -1) { return parent::skip($length); http://cvs.php.net/diff.php/pear/File_Archive/Archive/Reader/Memory.php?r1=1.10&r2=1.11&ty=u Index: pear/File_Archive/Archive/Reader/Memory.php diff -u pear/File_Archive/Archive/Reader/Memory.php:1.10 pear/File_Archive/Archive/Reader/Memory.php:1.11 --- pear/File_Archive/Archive/Reader/Memory.php:1.10 Wed May 4 09:53:40 2005 +++ pear/File_Archive/Archive/Reader/Memory.php Sat May 21 18:25:23 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.10 2005/05/04 13:53:40 vincentlascaux Exp $ + * @version CVS: $Id: Memory.php,v 1.11 2005/05/21 22:25:23 vincentlascaux Exp $ * @link http://pear.php.net/package/File_Archive */ @@ -82,7 +82,7 @@ $this->memory = &$memory; $this->filename = $this->getStandardURL($filename); $this->stat = $stat; - $this->stat[7] = strlen($this->memory); + $this->stat[7] = $this->stat['size'] = strlen($this->memory); $this->mime = $mime; } http://cvs.php.net/diff.php/pear/File_Archive/Archive/Reader/Tar.php?r1=1.15&r2=1.16&ty=u Index: pear/File_Archive/Archive/Reader/Tar.php diff -u pear/File_Archive/Archive/Reader/Tar.php:1.15 pear/File_Archive/Archive/Reader/Tar.php:1.16 --- pear/File_Archive/Archive/Reader/Tar.php:1.15 Fri May 6 16:19:49 2005 +++ pear/File_Archive/Archive/Reader/Tar.php Sat May 21 18:25:23 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.15 2005/05/06 20:19:49 vincentlascaux Exp $ + * @version CVS: $Id: Tar.php,v 1.16 2005/05/21 22:25:23 vincentlascaux Exp $ * @link http://pear.php.net/package/File_Archive */ @@ -40,13 +40,13 @@ * @var String Name of the file being read * @access private */ - var $currentFilename = NULL; + var $currentFilename = null; /** * @var Array Stats of the file being read * In TAR reader, indexes 2, 4, 5, 7, 9 are set * @access private */ - var $currentStat = NULL; + var $currentStat = null; /** * @var int Number of bytes that still have to be read before the end of * file @@ -138,6 +138,12 @@ 7 => octdec($header['size']), 9 => octdec($header['mtime']) ); + $this->currentStat['mode'] = $this->currentStat[2]; + $this->currentStat['uid'] = $this->currentStat[4]; + $this->currentStat['gid'] = $this->currentStat[5]; + $this->currentStat['size'] = $this->currentStat[7]; + $this->currentStat['mtime'] = $this->currentStat[9]; + if ($header['magic'] == 'ustar') { $this->currentFilename = $this->getStandardURL( $header['prefix'] . $header['filename'] http://cvs.php.net/diff.php/pear/File_Archive/Archive/Reader/Zip.php?r1=1.13&r2=1.14&ty=u Index: pear/File_Archive/Archive/Reader/Zip.php diff -u pear/File_Archive/Archive/Reader/Zip.php:1.13 pear/File_Archive/Archive/Reader/Zip.php:1.14 --- pear/File_Archive/Archive/Reader/Zip.php:1.13 Fri May 6 16:19:49 2005 +++ pear/File_Archive/Archive/Reader/Zip.php Sat May 21 18:25:23 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.13 2005/05/06 20:19:49 vincentlascaux Exp $ + * @version CVS: $Id: Zip.php,v 1.14 2005/05/21 22:25:23 vincentlascaux Exp $ * @link http://pear.php.net/package/File_Archive */ @@ -143,6 +143,8 @@ (($this->header['Date'] & 0xFE00) >> 9) + 1980 //year ) ); + $this->currentStat['size'] = $this->currentStat[7]; + $this->currentStat['mtime'] = $this->currentStat[9]; $this->currentFilename = $this->source->getData($this->header['File']);
http://cvs.php.net/diff.php/pear/File_Archive/Archive/Reader/Concat.php?r1=1.8&r2=1.9&ty=u Index: pear/File_Archive/Archive/Reader/Concat.php diff -u pear/File_Archive/Archive/Reader/Concat.php:1.8 pear/File_Archive/Archive/Reader/Concat.php:1.9 --- pear/File_Archive/Archive/Reader/Concat.php:1.8 Wed May 4 09:53:40 2005 +++ pear/File_Archive/Archive/Reader/Concat.php Sat May 21 18:25:23 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: Concat.php,v 1.8 2005/05/04 13:53:40 vincentlascaux Exp $ + * @version CVS: $Id: Concat.php,v 1.9 2005/05/21 22:25:23 vincentlascaux Exp $ * @link http://pear.php.net/package/File_Archive */ @@ -55,7 +55,15 @@ $this->stat[7] = 0; while (($error = $source->next()) === true) { $sourceStat = $source->getStat(); - $this->stat[7] += $sourceStat[7]; + if (isset($sourceStat[7])) { + $this->stat[7] += $sourceStat[7]; + } else { + unset($this->stat[7]); + break; + } + } + if (isset($this->stat[7])) { + $this->stat['size'] = $this->stat[7]; } if (PEAR::isError($error) || PEAR::isError($source->close())) { die("Error in File_Archive_Reader_Concat constructor ". http://cvs.php.net/diff.php/pear/File_Archive/Archive/Reader/File.php?r1=1.15&r2=1.16&ty=u Index: pear/File_Archive/Archive/Reader/File.php diff -u pear/File_Archive/Archive/Reader/File.php:1.15 pear/File_Archive/Archive/Reader/File.php:1.16 --- pear/File_Archive/Archive/Reader/File.php:1.15 Fri May 13 19:32:25 2005 +++ pear/File_Archive/Archive/Reader/File.php Sat May 21 18:25:23 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.15 2005/05/13 23:32:25 vincentlascaux Exp $ + * @version CVS: $Id: File.php,v 1.16 2005/05/21 22:25:23 vincentlascaux Exp $ * @link http://pear.php.net/package/File_Archive */ @@ -58,13 +58,6 @@ * @access private */ var $stat = null; - /** - * @var File_Archive_Reader_Memory If we can't use stat on the URL, we need - * to read the whole file to compute its length. In this case $memory - * won't be null, and store the content of the file - * @access private - */ - var $memory = null; /** * $filename is the physical file to read @@ -108,7 +101,6 @@ if (!is_resource($this->handle)) { return PEAR::raiseError("Can't open {$this->filename} for reading"); } - $this->memory = null; if ($this->handle === false) { return PEAR::raiseError("File {$this->filename} not found"); } else { @@ -135,16 +127,7 @@ //If we can't use the stat function if ($this->stat === false) { - $alreadyRead = ftell($this->handle); - - //Put the whole file content in memory - require_once "Memory.php"; - $this->memory = new File_Archive_Reader_Memory( - $this->getData(), - $this->symbolic); - - $this->stat = $this->memory->getStat(); - $this->stat = array(7 => $this->stat[7] + $alreadyRead); + $this->stat = array(); } } return $this->stat; @@ -168,10 +151,6 @@ */ function getData($length = -1) { - if ($this->memory != null) { - return $this->memory->getData($length); - } - if (feof($this->handle)) { return null; } @@ -194,10 +173,6 @@ */ function skip($length) { - if ($this->memory != null) { - return $this->memory->skip($length); - } - $before = ftell($this->handle); if (@fseek($this->handle, $length, SEEK_CUR) === -1) { return parent::skip($length); http://cvs.php.net/diff.php/pear/File_Archive/Archive/Reader/Memory.php?r1=1.10&r2=1.11&ty=u Index: pear/File_Archive/Archive/Reader/Memory.php diff -u pear/File_Archive/Archive/Reader/Memory.php:1.10 pear/File_Archive/Archive/Reader/Memory.php:1.11 --- pear/File_Archive/Archive/Reader/Memory.php:1.10 Wed May 4 09:53:40 2005 +++ pear/File_Archive/Archive/Reader/Memory.php Sat May 21 18:25:23 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.10 2005/05/04 13:53:40 vincentlascaux Exp $ + * @version CVS: $Id: Memory.php,v 1.11 2005/05/21 22:25:23 vincentlascaux Exp $ * @link http://pear.php.net/package/File_Archive */ @@ -82,7 +82,7 @@ $this->memory = &$memory; $this->filename = $this->getStandardURL($filename); $this->stat = $stat; - $this->stat[7] = strlen($this->memory); + $this->stat[7] = $this->stat['size'] = strlen($this->memory); $this->mime = $mime; } http://cvs.php.net/diff.php/pear/File_Archive/Archive/Reader/Tar.php?r1=1.15&r2=1.16&ty=u Index: pear/File_Archive/Archive/Reader/Tar.php diff -u pear/File_Archive/Archive/Reader/Tar.php:1.15 pear/File_Archive/Archive/Reader/Tar.php:1.16 --- pear/File_Archive/Archive/Reader/Tar.php:1.15 Fri May 6 16:19:49 2005 +++ pear/File_Archive/Archive/Reader/Tar.php Sat May 21 18:25:23 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.15 2005/05/06 20:19:49 vincentlascaux Exp $ + * @version CVS: $Id: Tar.php,v 1.16 2005/05/21 22:25:23 vincentlascaux Exp $ * @link http://pear.php.net/package/File_Archive */ @@ -40,13 +40,13 @@ * @var String Name of the file being read * @access private */ - var $currentFilename = NULL; + var $currentFilename = null; /** * @var Array Stats of the file being read * In TAR reader, indexes 2, 4, 5, 7, 9 are set * @access private */ - var $currentStat = NULL; + var $currentStat = null; /** * @var int Number of bytes that still have to be read before the end of * file @@ -138,6 +138,12 @@ 7 => octdec($header['size']), 9 => octdec($header['mtime']) ); + $this->currentStat['mode'] = $this->currentStat[2]; + $this->currentStat['uid'] = $this->currentStat[4]; + $this->currentStat['gid'] = $this->currentStat[5]; + $this->currentStat['size'] = $this->currentStat[7]; + $this->currentStat['mtime'] = $this->currentStat[9]; + if ($header['magic'] == 'ustar') { $this->currentFilename = $this->getStandardURL( $header['prefix'] . $header['filename'] http://cvs.php.net/diff.php/pear/File_Archive/Archive/Reader/Zip.php?r1=1.13&r2=1.14&ty=u Index: pear/File_Archive/Archive/Reader/Zip.php diff -u pear/File_Archive/Archive/Reader/Zip.php:1.13 pear/File_Archive/Archive/Reader/Zip.php:1.14 --- pear/File_Archive/Archive/Reader/Zip.php:1.13 Fri May 6 16:19:49 2005 +++ pear/File_Archive/Archive/Reader/Zip.php Sat May 21 18:25:23 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.13 2005/05/06 20:19:49 vincentlascaux Exp $ + * @version CVS: $Id: Zip.php,v 1.14 2005/05/21 22:25:23 vincentlascaux Exp $ * @link http://pear.php.net/package/File_Archive */ @@ -143,6 +143,8 @@ (($this->header['Date'] & 0xFE00) >> 9) + 1980 //year ) ); + $this->currentStat['size'] = $this->currentStat[7]; + $this->currentStat['mtime'] = $this->currentStat[9]; $this->currentFilename = $this->source->getData($this->header['File']);