From: Tomas V.V.Cox Date: Tue, 17 Jul 2001 19:13:40 +0000 (+0000) Subject: moved methods log() and mkdirHier() from Packager/Installer to here X-Git-Tag: PRE_TSRM_MERGE_PATCH~103 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5cb96db14385f5fadac29415b402afb8d943a65b;p=php moved methods log() and mkdirHier() from Packager/Installer to here --- diff --git a/pear/PEAR/Common.php b/pear/PEAR/Common.php index bc50e3523c..f8fbfde2d1 100644 --- a/pear/PEAR/Common.php +++ b/pear/PEAR/Common.php @@ -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)