svn: /pear/packages/File_Archive/trunk/File/ Archive/Predicate/Preg.php Archive.php
| From: | Daniel O'Connor | Date: | Mon, 06 Sep 2010 14:56:58 +0000 |
| Subject: | svn: /pear/packages/File_Archive/trunk/File/ Archive/Predicate/Preg.php Archive.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-60272@lists.php.net to get a copy of this message | ||
clockwerx Mon, 06 Sep 2010 14:56:58 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=303088
Log:
Bug #17836 Provide an alternative implementation to deprecated functionality
Bug: http://pear.php.net/bugs/17836 (unknown)
Changed paths:
A pear/packages/File_Archive/trunk/File/Archive/Predicate/Preg.php
U pear/packages/File_Archive/trunk/File/Archive.php
Added: pear/packages/File_Archive/trunk/File/Archive/Predicate/Preg.php
===================================================================
--- pear/packages/File_Archive/trunk/File/Archive/Predicate/Preg.php (rev 0)
+++ pear/packages/File_Archive/trunk/File/Archive/Predicate/Preg.php 2010-09-06 14:56:58 UTC (rev
303088)
@@ -0,0 +1,59 @@
+<?php
+/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
+
+/**
+ * Keep only the files which name follow a given regular expression
+ *
+ * PHP versions 4 and 5
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * 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: Ereg.php 260736 2008-06-04 13:16:07Z cbrunet $
+ * @link http://pear.php.net/package/File_Archive
+ */
+
+require_once "File/Archive/Predicate.php";
+
+/**
+ * Keep only the files which name follow a given regular expression
+ *
+ * @see File_Archive_Predicate, File_Archive_Reader_Filter ereg
+ */
+class File_Archive_Predicate_Preg extends File_Archive_Predicate
+{
+ var $preg;
+
+ /**
+ * @param string $ereg is the regular expression
+ */
+ function File_Archive_Predicate_Preg($preg)
+ {
+ $this->preg = $preg;
+ }
+ /**
+ * @see File_Archive_Predicate::isTrue()
+ */
+ function isTrue(&$source)
+ {
+ return (bool)preg_match($this->preg, $source->getFilename());
+ }
+}
+
+?>
Property changes on: pear/packages/File_Archive/trunk/File/Archive/Predicate/Preg.php
___________________________________________________________________
Added: svn:executable
+ *
Modified: pear/packages/File_Archive/trunk/File/Archive.php
===================================================================
--- pear/packages/File_Archive/trunk/File/Archive.php 2010-09-06 14:56:33 UTC (rev 303087)
+++ pear/packages/File_Archive/trunk/File/Archive.php 2010-09-06 14:56:58 UTC (rev 303088)
@@ -325,7 +325,7 @@
$result = File_Archive::_readSource($source, $baseFile,
$reachable, $baseDir, null, 0, -1);
return File_Archive::filter(
- File_Archive::predEreg('^'.$regexp.'$'),
+ File_Archive::predPreg('/^'.$regexp.'$/'),
$result
);
}
@@ -936,12 +936,27 @@
require_once "File/Archive/Predicate/MIME.php";
return new File_Archive_Predicate_MIME($list);
}
+
/**
* Evaluates to true iif the name of the file follow a given regular
* expression
*
+ * @param string $preg regular expression that the filename must follow
+ * @see File_Archive_Predicate_Preg, preg_match()
+ */
+ function predPreg($preg)
+ {
+ require_once "File/Archive/Predicate/Preg.php";
+ return new File_Archive_Predicate_Preg($preg);
+ }
+
+ /**
+ * Evaluates to true iif the name of the file follow a given regular
+ * expression
+ *
* @param string $ereg regular expression that the filename must follow
* @see File_Archive_Predicate_Ereg, ereg()
+ * @deprecated Make use of predPreg instead for PHP 5.3+ compatability
*/
function predEreg($ereg)
{
@@ -954,6 +969,7 @@
*
* @param string $ereg regular expression that the filename must follow
* @see File_Archive_Predicate_Eregi, eregi
+ * @deprecated Make use of predPreg instead for PHP 5.3+ compatability
*/
function predEregi($ereg)
{