]> granicus.if.org Git - php/commitdiff
* added listPackages
authorStig Bakken <ssb@php.net>
Sun, 28 Oct 2001 23:35:10 +0000 (23:35 +0000)
committerStig Bakken <ssb@php.net>
Sun, 28 Oct 2001 23:35:10 +0000 (23:35 +0000)
* made packageInfo param optional, if not specified returns info for
  all packages

pear/PEAR/Registry.php

index 06585cc50811b45c0ba5cb153b2de3ee0c49b381..0ade71338f01cf81372c07798910ad4406c4a74d 100644 (file)
@@ -55,7 +55,6 @@ class PEAR_Registry
 
     function _packageFileName($package)
     {
-        $package = strtolower($package);
         return "{$this->statedir}/{$package}.inf";
     }
 
@@ -104,8 +103,12 @@ class PEAR_Registry
     // }}}
     // {{{ packageInfo()
 
-    function packageInfo($package)
+    function packageInfo($package = null)
     {
+        if ($package === null) {
+            return array_map(array($this, "packageInfo"),
+                             $this->listPackages());
+        }
         $fp = $this->_openPackageFile($package, "r");
         $data = fread($fp, filesize($this->_packageFileName($package)));
         $this->_closePackageFile($fp);
@@ -136,7 +139,22 @@ class PEAR_Registry
     }
 
     // }}}
+    // {{{ listPackages()
+
+    function listPackages()
+    {
+        $dp = opendir($this->statedir);
+        $pkglist = array();
+        while ($ent = readdir($dp)) {
+            if ($ent{0} == "." || substr($ent, -4) != ".inf") {
+                continue;
+            }
+            $pkglist[] = substr($entry, 0, -4);
+        }
+        return $pkglist;
+    }
 
+    // }}}
 }
 
 ?>
\ No newline at end of file