From: Tomas V.V.Cox Date: Mon, 8 Oct 2001 06:10:54 +0000 (+0000) Subject: added mkTempDir to create temporal directories X-Git-Tag: PRE_PARAMETER_PARSING_API~36 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5f5bbfd3f3e3d8c2fa166afe93bf81d4f3776dd9;p=php added mkTempDir to create temporal directories --- 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)