]> granicus.if.org Git - php/commitdiff
moved methods log() and mkdirHier() from Packager/Installer to here
authorTomas V.V.Cox <cox@php.net>
Tue, 17 Jul 2001 19:13:40 +0000 (19:13 +0000)
committerTomas V.V.Cox <cox@php.net>
Tue, 17 Jul 2001 19:13:40 +0000 (19:13 +0000)
pear/PEAR/Common.php

index bc50e3523c1a98f9678c068f5c45fb24cee3b65b..f8fbfde2d18f10e05faf01a53061c1c333fae9ae 100644 (file)
@@ -18,7 +18,7 @@
 // +----------------------------------------------------------------------+
 //
 
-require_once "PEAR.php";
+require_once 'PEAR.php';
 
 class PEAR_Common extends PEAR
 {
@@ -74,6 +74,37 @@ class PEAR_Common extends PEAR
     }
 
     // }}}
+    // {{{ mkDirHier()
+
+    function mkDirHier($dir)
+    {
+        $dirstack = array();
+        while (!@is_dir($dir) && $dir != DIRECTORY_SEPARATOR) {
+            array_unshift($dirstack, $dir);
+            $dir = dirname($dir);
+        }
+        while ($newdir = array_shift($dirstack)) {
+            if (mkdir($newdir, 0777)) {
+                $this->log(2, "created dir $newdir");
+            } else {
+                return false;
+            }
+        }
+        return true;
+    }
+
+    // }}}
+    // {{{ log()
+
+    function log($level, $msg)
+    {
+        if ($this->debug >= $level) {
+            print "$msg\n";
+        }
+    }
+
+    // }}}
+
     // {{{ _element_start()
 
     function _element_start($xp, $name, $attribs)