From: Stig Bakken Date: Sun, 28 Oct 2001 23:35:10 +0000 (+0000) Subject: * added listPackages X-Git-Tag: ChangeLog~500 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c62fdf8f11a27d24988ac8251a1000cde3d84365;p=php * added listPackages * made packageInfo param optional, if not specified returns info for all packages --- diff --git a/pear/PEAR/Registry.php b/pear/PEAR/Registry.php index 06585cc508..0ade71338f 100644 --- a/pear/PEAR/Registry.php +++ b/pear/PEAR/Registry.php @@ -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