svn: /pear/packages/File_Archive/trunk/Archive/Reader/ ChangeName.php
| From: | Charles Brunet | Date: | Sun, 07 Mar 2010 12:58:22 +0000 |
| Subject: | svn: /pear/packages/File_Archive/trunk/Archive/Reader/ ChangeName.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-59014@lists.php.net to get a copy of this message | ||
cbrunet Sun, 07 Mar 2010 12:58:22 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=295919
Log:
Bug #17046: added missing constructor.
Bug: http://pear.php.net/bugs/17046 (unknown)
Changed paths:
U pear/packages/File_Archive/trunk/Archive/Reader/ChangeName.php
Modified: pear/packages/File_Archive/trunk/Archive/Reader/ChangeName.php
===================================================================
--- pear/packages/File_Archive/trunk/Archive/Reader/ChangeName.php 2010-03-07 10:55:04 UTC (rev
295918)
+++ pear/packages/File_Archive/trunk/Archive/Reader/ChangeName.php 2010-03-07 12:58:22 UTC (rev
295919)
@@ -20,26 +20,44 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330,Boston,MA 02111-1307 USA
*
- * @category File Formats
- * @package File_Archive
- * @author Vincent Lascaux <vincentlascaux@php.net>
- * @copyright 1997-2005 The PHP Group
- * @license http://www.gnu.org/copyleft/lesser.html LGPL
- * @version CVS: $Id$
- * @link http://pear.php.net/package/File_Archive
+ * @category File_Formats
+ * @package File_Archive
+ * @author Vincent Lascaux <vincentlascaux@php.net>
+ * @copyright 1997-2005 The PHP Group
+ * @license http://www.gnu.org/copyleft/lesser.html LGPL
+ * @version CVS: $Id$
+ * @link http://pear.php.net/package/File_Archive
*/
require_once "File/Archive/Reader/Relay.php";
/**
* Base class for readers that need to modify the name of files
+ *
+ * @category File_Formats
+ * @package File_Archive
+ * @author Vincent Lascaux <vincentlascaux@php.net>
+ * @copyright 1997-2005 The PHP Group
+ * @license http://www.gnu.org/copyleft/lesser.html LGPL
+ * @link http://pear.php.net/package/File_Archive
*/
class File_Archive_Reader_ChangeName extends File_Archive_Reader_Relay
{
/**
+ * Constructor
+ *
+ * @param File_Archive_Reader &$source The archive reader to relay
+ */
+ function File_Archive_Reader_ChangeName(&$source)
+ {
+ parent::File_Archive_Reader_Relay($source);
+ }
+
+ /**
* Modify the name
*
* @param string $name Name as in the inner reader
+ *
* @return string New name as shown by this reader or false is the
* file or directory has to be skipped
*/
@@ -56,11 +74,12 @@
* something more efficient with an index for example could be used on
* the inner reader of the original name is known).
*
- * unmodifyName may be provided some names that where not in the inner reader
- * and that cannot possibly be the result of modifyName. In this case
+ * unmodifyName may be provided some names that where not in the inner
+ * reader and that cannot possibly be the result of modifyName. In this case
* unmodifyName must return false.
*
* @param string $name Name as shown by this reader
+ *
* @return string Name as in the inner reader, or false if there is no
* input such that modifyName would return $name or a file in
* a directory called $name
@@ -71,25 +90,52 @@
}
/**
+ * Returns the name of the file currently read by the reader
+ *
+ * Warning: undefined behaviour if no call to next have been
+ * done or if last call to next has returned false
+ *
+ * @return string Name of the current file
* @see File_Archive_Reader::getFilename()
*/
function getFilename()
{
return $this->getStandardURL($this->modifyName(parent::getFilename()));
}
+
/**
+ * Returns the list of filenames from the current pos to the end of the
+ * source
+ *
+ * The source will be closed after having called this function
+ * This function goes through the whole archive (which may be slow).
+ * If you intend to work on the reader, doing it in one pass would be faster
+ *
+ * @return array filenames from the current pos to the end of the source
* @see File_Archive_Reader::getFileList()
*/
function getFileList()
{
- $list = parent::getFileList();
+ $list = parent::getFileList();
$result = array();
foreach ($list as $name) {
$result[] = $this->modifyName($name);
}
return $result;
}
+
/**
+ * Returns the list of filenames from the current pos to the end of the
+ * source
+ *
+ * The source will be closed after having called this function
+ * This function goes through the whole archive (which may be slow).
+ * If you intend to work on the reader, doing it in one pass would be faster
+ *
+ * @param string $filename Filename to choose
+ * @param boolaen $close Do we close the source after?
+ *
+ * @return array filenames from the current pos to the end of the source
* @see File_Archive_Reader::select()
*/
function select($filename, $close = true)
@@ -97,7 +143,7 @@
$name = $this->unmodifyName($filename);
if ($name === false) {
return false;
- } else if($name === null) {
+ } else if ($name === null) {
$std = $this->getStandardURL($filename);
if (substr($std, -1)=='/') {
$std = substr($std, 0, -1);
@@ -111,18 +157,15 @@
}
while (($error = $this->next()) === true) {
$sourceName = $this->getFilename();
- $sourceName = $this->modifyName($sourceName, $this->isDirectory());
+ $sourceName = $this->modifyName(
+ $sourceName, $this->isDirectory()
+ );
$sourceName = $this->getStandardURL($sourceName);
- if (
- empty($std) ||
-
- //$std is a file
- $std == $sourceName ||
-
- //$std is a directory
- (strncmp($std.'/', $sourceName, strlen($std)+1) == 0 &&
- strlen($sourceName) > strlen($std)+1)
- ) {
+ if (empty($std)
+ || $std == $sourceName //$std is a file
+ || (strncmp($std.'/', $sourceName, strlen($std)+1) == 0
+ && strlen($sourceName) > strlen($std)+1) //$std is a directory
+ ) {
return true;
}
}
@@ -133,4 +176,4 @@
}
}
-?>
\ No newline at end of file
+?>