summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'class.portage.tree.php')
-rw-r--r--class.portage.tree.php27
1 files changed, 21 insertions, 6 deletions
diff --git a/class.portage.tree.php b/class.portage.tree.php
index c9ba655..e413990 100644
--- a/class.portage.tree.php
+++ b/class.portage.tree.php
@@ -2,27 +2,42 @@
class PortageTree {
+ private static $instance;
+
// Strings
protected $tree;
// Arrays
protected $arr_licenses;
- function __construct($tree = "/usr/portage") {
+ public function __construct($tree = "/usr/portage") {
+
+ global $hits;
+ $hits['tree']++;
+
if($tree)
$this->setTree($tree);
}
- function getTree() {
+ public static function singleton() {
+ if (!isset(self::$instance)) {
+ $c = __CLASS__;
+ self::$instance = new $c;
+ }
+
+ return self::$instance;
+ }
+
+ public function getTree() {
return $this->tree;
}
- function setTree($x) {
+ public function setTree($x) {
if(is_string($x) && is_dir($x))
$this->tree = $x;
}
- function getArches($prefix = false) {
+ public function getArches($prefix = false) {
$filename = $this->getTree().'/profiles/arch.list';
$arr = file($filename, FILE_IGNORE_NEW_LINES);
@@ -79,7 +94,7 @@
}
- function getLicenses() {
+ public function getLicenses() {
$scandir = scandir($this->getTree().'/licenses/');
$scandir = preg_grep('/^\.{1,2}$/', $scandir, PREG_GREP_INVERT);
@@ -132,7 +147,7 @@
*
* @return array
*/
- function getHerds() {
+ public function getHerds() {
$arr = array();