cvs: pear /PHP_Archive Archive.php

From: Date: Tue, 12 Apr 2005 05:05:27 +0000
Subject: cvs: pear /PHP_Archive Archive.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-31115@lists.php.net to get a copy of this message
cellog Tue Apr 12 01:05:27 2005 EDT Modified files: /pear/PHP_Archive Archive.php Log: tabs -> spaces start opendir access code, so that .phars can operate on themselves using opendir()/readdir() http://cvs.php.net/diff.php/pear/PHP_Archive/Archive.php?r1=1.7&r2=1.8&ty=u Index: pear/PHP_Archive/Archive.php diff -u pear/PHP_Archive/Archive.php:1.7 pear/PHP_Archive/Archive.php:1.8 --- pear/PHP_Archive/Archive.php:1.7 Sat Apr 9 00:45:13 2005 +++ pear/PHP_Archive/Archive.php Tue Apr 12 01:05:26 2005 @@ -4,6 +4,7 @@ * * @package PHP_Archive * @category PHP + * @todo finish opendir/readdir/rewinddir/closedir code */ /** @@ -20,7 +21,7 @@ * @author Davey Shafik <davey@synapticmedia.net> * @author Greg Beaver <cellog@php.net> * @link http://www.synapticmedia.net Synaptic Media - * @version $Id: Archive.php,v 1.7 2005/04/09 04:45:13 cellog Exp $ + * @version $Id: Archive.php,v 1.8 2005/04/12 05:05:26 cellog Exp $ * @package PHP_Archive * @category PHP */ @@ -227,9 +228,17 @@ } else { $test = false; } - while (strpos($this->archiveName, 'phar://') === 0 && - (!$test || !strpos($this->archiveName, $test))) { + while (count($aname)) { $this->archiveName = array_pop($aname); + if (strpos($this->archiveName, 'phar://') === false) { + if ($test) { + if (strpos($this->archiveName, $test)) { + break; + } + } else { + break; + } + } } if ($test && $this->archiveName != 'phar://') { $file = substr($file, strlen($test) + 1); @@ -299,8 +308,8 @@ function stream_read($count) { $ret = substr($this->file, $this->position, $count); - $this->position += strlen($ret); - return $ret; + $this->position += strlen($ret); + return $ret; } /** @@ -308,43 +317,55 @@ */ function stream_eof() - { - return $this->position >= strlen($this->file); - } - - /** - * For seeking the stream, does nothing - */ - - function stream_seek() { - return true; - } - - /** - * The current position in the stream - */ - - function stream_tell() { - return $this->position; - } - - /** - * The result of an fstat call, returns mod time from tar, and file size - */ - - function stream_stat() { - return array( - 'mtime' => $this->currentStat[9], - 'atime' => $this->currentStat[9], - 'ctime' => $this->currentStat[9], - 'size' => strlen($this->file), - ); - } - - function APIVersion() - { - return '0.5'; - } + { + return $this->position >= strlen($this->file); + } + + /** + * For seeking the stream + */ + + function stream_seek($pos) { + $this->position = $pos; + return true; + } + + /** + * The current position in the stream + */ + + function stream_tell() { + return $this->position; + } + + /** + * The result of an fstat call, returns mod time from tar, and file size + */ + + function stream_stat() { + return array( + 'size' => strlen($this->file), + 'atime' => $this->currentStat[9], + 'mtime' => $this->currentStat[9], + 'ctime' => $this->currentStat[9], + ); + } + + /** + * Open a directory in the .phar for reading + */ + function dir_opendir($path) + { + $path = $this->initializeStream($path); + if ($this->archiveName == 'phar://') { + trigger_error('Error: Unknown phar in "' . $file . '"', E_USER_ERROR); + } + } + + function APIVersion() + { + return '0.5'; + } } ?> \ No newline at end of file

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