From 5f5bbfd3f3e3d8c2fa166afe93bf81d4f3776dd9 Mon Sep 17 00:00:00 2001 From: "Tomas V.V.Cox" Date: Mon, 8 Oct 2001 06:10:54 +0000 Subject: [PATCH] added mkTempDir to create temporal directories --- pear/PEAR/Common.php | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/pear/PEAR/Common.php b/pear/PEAR/Common.php index a93631877b..2c963cb5cf 100644 --- a/pear/PEAR/Common.php +++ b/pear/PEAR/Common.php @@ -79,7 +79,7 @@ class PEAR_Common extends PEAR $file = array_shift($this->_tempfiles)) { if (@is_dir($file)) { - System::rm("-rf $file"); // XXX FIXME Windows + System::rm("-rf $file"); } elseif (file_exists($file)) { unlink($file); } @@ -105,7 +105,7 @@ class PEAR_Common extends PEAR $dir = dirname($dir); } while ($newdir = array_shift($dirstack)) { - if (mkdir($newdir, 0777)) { + if (mkdir($newdir, 0755)) { $this->log(2, "+ created dir $newdir"); } else { return false; @@ -126,6 +126,18 @@ class PEAR_Common extends PEAR // }}} + function mkTempDir() + { + $dir = (OS_WINDOWS) ? 'c:\\windows\\temp' : '/tmp'; + $tmpdir = tempnam($tmpdir, 'pear'); + unlink($tmpdir); + if (!mkdir($tmpdir, 0700)) { + return $this->raiseError("Unable to create temporary directory $tmpdir"); + } + $this->addTempFile($tmpdir); + return $tmpdir; + } + // {{{ _element_start() function _element_start($xp, $name, $attribs) -- 2.50.1