From: Tomas V.V.Cox Date: Sun, 16 Dec 2001 15:14:00 +0000 (+0000) Subject: use the System class for mkDirHier() and mkTempDir() X-Git-Tag: PRE_ISSET_PATCH~523 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e2a5cf3fcbd9257707d08a247978ae6664f5c2b3;p=php use the System class for mkDirHier() and mkTempDir() --- diff --git a/pear/PEAR/Common.php b/pear/PEAR/Common.php index 881510e00d..663124cae7 100644 --- a/pear/PEAR/Common.php +++ b/pear/PEAR/Common.php @@ -100,19 +100,8 @@ class PEAR_Common extends PEAR 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, 0755)) { - $this->log(2, "+ created dir $newdir"); - } else { - return false; - } - } - return true; + $this->log(2, "+ create dir $dir"); + return System::mkDir("-p $dir"); } // }}} @@ -130,11 +119,9 @@ class PEAR_Common extends PEAR function mkTempDir() { - $dir = (OS_WINDOWS) ? 'c:\\windows\\temp' : '/tmp'; - $tmpdir = tempnam($dir, 'pear'); - unlink($tmpdir); - if (!mkdir($tmpdir, 0700)) { - return $this->raiseError("Unable to create temporary directory $tmpdir"); + $tmpdir = System::mktemp('-d pear'); + if (PEAR::isError($tmpdir)) { + return $tmpdir; } $this->addTempFile($tmpdir); return $tmpdir;