cvs: php4 /pear/File Find.php
| From: | Sterling Hughes | Date: | Tue, 21 Aug 2001 04:02:51 +0000 |
| Subject: | cvs: php4 /pear/File Find.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-610@lists.php.net to get a copy of this message | ||
sterling Tue Aug 21 00:02:51 2001 EDT
Modified files:
/php4/pear/File Find.php
Log:
More ws
Index: php4/pear/File/Find.php
diff -u php4/pear/File/Find.php:1.17 php4/pear/File/Find.php:1.18
--- php4/pear/File/Find.php:1.17 Mon Aug 20 23:57:34 2001
+++ php4/pear/File/Find.php Tue Aug 21 00:02:48 2001
@@ -16,7 +16,7 @@
// | Authors: Sterling Hughes <sterling@php.net> |
// +----------------------------------------------------------------------+
//
-// $Id: Find.php,v 1.17 2001/08/21 03:57:34 sterling Exp $
+// $Id: Find.php,v 1.18 2001/08/21 04:02:48 sterling Exp $
//
require_once 'PEAR.php';
@@ -25,7 +25,7 @@
* Commonly needed functions searching directory trees
*
* @access public
-* @version $Id: Find.php,v 1.17 2001/08/21 03:57:34 sterling Exp $
+* @version $Id: Find.php,v 1.18 2001/08/21 04:02:48 sterling Exp $
* @package File
* @author Sterling Hughes <sterling@php.net>
*/
@@ -72,22 +72,22 @@
$dh = @opendir ($dirpath);
if (!$dh) {
- $pe = new FileFindException ("Cannot open directory");
+ $pe = new FileFindException("Cannot open directory");
return ($pe);
}
- $match_function = File_Find::_determineRegex ($pattern, $pattern_type);
+ $match_function = File_Find::_determineRegex($pattern, $pattern_type);
$matches = array();
while ($entry = @readdir ($dh)) {
- if ($match_function ($pattern, $entry) &&
- $entry != '.' &&
+ if ($match_function($pattern, $entry) &&
+ $entry != '.' &&
$entry != '..') {
$matches[] = $entry;
}
}
@closedir ($dh);
- return (sizeof($matches) > 0) ? $matches : null;
+ return count($matches) > 0 ? $matches : null;
}
/**
@@ -105,15 +105,15 @@
*/
function &maptree ($directory)
{
- $this->_dirs = array ($directory);
+ $this->_dirs = array($directory);
- while (count ($this->_dirs)) {
- $dir = array_pop ($this->_dirs);
- File_Find::_build ($dir);
- array_push ($this->directories, $dir);
+ while (count($this->_dirs)) {
+ $dir = array_pop($this->_dirs);
+ File_Find::_build($dir);
+ array_push($this->directories, $dir);
}
- return array ($this->directories, $this->files);
+ return array($this->directories, $this->files);
}
/**
@@ -134,12 +134,12 @@
* @access public
*/
function &search ($pattern, $directory, $type='php') {
- list (,$files) = File_Find::maptree ($directory);
- $match_function = File_Find::_determineRegex ($pattern, $type);
+ list (,$files) = File_Find::maptree($directory);
+ $match_function = File_Find::_determineRegex($pattern, $type);
- reset ($files);
- while (list (,$entry) = each ($files)) {
- if ($match_function ($pattern, $entry))
+ reset($files);
+ while (list(,$entry) = each($files)) {
+ if ($match_function($pattern, $entry))
$matches[] = $entry;
}
@@ -167,7 +167,7 @@
*/
function File_Find_version()
{
- return (1.1);
+ return 1.1;
}
/**
* internal function to build singular directory trees, used by
@@ -181,26 +181,26 @@
$dh = @opendir ($directory);
if (!$dh) {
- $pe = new FileFindException ("Cannot open directory");
- return ($pe);
+ $pe = new FileFindException("Cannot open directory");
+ return $pe;
}
- while ($entry = @readdir ($dh)) {
+ while ($entry = @readdir($dh)) {
if ($entry != '.' &&
$entry != '..') {
$entry = "$directory/$entry";
- if (is_dir ($entry))
- array_push ($this->_dirs, $entry);
+ if (is_dir($entry))
+ array_push($this->_dirs, $entry);
else
- array_push ($this->files, $entry);
+ array_push($this->files, $entry);
}
}
- @closedir ($dh);
+ @closedir($dh);
}
/**
@@ -213,15 +213,15 @@
*/
function _determineRegex ($pattern, $type)
{
- if (! strcasecmp ($type, 'perl')) {
+ if (! strcasecmp($type, 'perl')) {
$match_function = 'preg_match';
- } else if (! strcasecmp (substr ($pattern, -2), '/i')) {
+ } else if (! strcasecmp(substr($pattern, -2), '/i')) {
$match_function = 'eregi';
} else {
$match_function = 'ereg';
}
- return ($match_function);
+ return $match_function;
}
//End Class
@@ -254,7 +254,7 @@
*/
function FileFindException ($message, $mode = PEAR_ERROR_RETURN, $level = E_USER_NOTICE)
{
- $this->PEAR_Error ($message, $mode, $level);
+ $this->PEAR_Error($message, $mode, $level);
}
}