com phpruntests: phpruntests - added a alternative parse-method in rtUtil: code-samples/dirList.php src/rtUtil.php
| From: | David Soria Parra | Date: | Mon, 22 Jun 2009 02:17:17 +0000 |
| Subject: | com phpruntests: phpruntests - added a alternative parse-method in rtUtil: code-samples/dirList.php src/rtUtil.php | ||
| Groups: | php.qa | ||
| Request: | Send a blank email to php-qa+get-66406@lists.php.net to get a copy of this message | ||
Commit: 03df5c497232c551820e45bead073a25519640a3
Author: Georg Gradwohl <g2@php.net> Mon, 22 Jun 2009 02:17:17 +0000
Parents: b28bedb73555b7509001ec4cba2c72f6b56c9b1e
Branches: master
Link: http://git.php.net/?p=phpruntests.git;a=commitdiff;h=03df5c497232c551820e45bead073a25519640a3
Log:
phpruntests - added a alternative parse-method in rtUtil
Changed paths:
A code-samples/dirList.php
M src/rtUtil.php
Diff:
diff --git a/code-samples/dirList.php b/code-samples/dirList.php
new file mode 100644
index 0000000..7853173
--- /dev/null
+++ b/code-samples/dirList.php
@@ -0,0 +1,43 @@
+<?php
+
+include '../src/rtUtil.php';
+
+
+// arguments
+
+$argc = sizeof($argv);
+
+if ($argc == 2 || $argc == 3) {
+
+ $dir = $argv[1];
+ $simple = isset($argv[2]) ? true : false;
+
+} else {
+
+ die("USAGE\n");
+}
+
+
+// execute
+
+if ($simple) {
+
+ print "rtUtil::parseDir\n";
+ $s = microtime(true);
+ $list = rtUtil::parseDir($dir);
+ $e = microtime(true);
+
+} else {
+
+ print "rtUtil::getDirectoryList\n";
+ $s = microtime(true);
+ $list = rtUtil::getDirectoryList($dir);
+ $e = microtime(true);
+}
+
+print "list:\t".sizeof($list)."\n";
+print "time:\t".round($e-$s, 5)."\n";
+print "mem:\t".memory_get_usage()."\n";
+
+?>
+
diff --git a/src/rtUtil.php b/src/rtUtil.php
index 2f6360c..3faf008 100644
--- a/src/rtUtil.php
+++ b/src/rtUtil.php
@@ -48,5 +48,35 @@ class rtUtil
return $phptDirectories;
}
+
+
+ /**
+ * just a test
+ *
+ * @param $path
+ * @return array
+ */
+ public static function parseDir($path) {
+
+ $list = array();
+
+ if (sizeof(glob($path."/*.phpt")) > 0) {
+
+ $list[] = $path.'/';
+ }
+
+ foreach (scandir($path) as $file) {
+
+ if (substr($file, 0, 1) != '.' && $file != 'CVS') {
+
+ if (is_dir($path.'/'.$file)) {
+
+ $list = array_merge($list, rtUtil::parseDir($path.'/'.$file));
+ }
+ }
+ }
+
+ return $list;
+ }
}
?>