]> granicus.if.org Git - php/commitdiff
added mkTempDir to create temporal directories
authorTomas V.V.Cox <cox@php.net>
Mon, 8 Oct 2001 06:10:54 +0000 (06:10 +0000)
committerTomas V.V.Cox <cox@php.net>
Mon, 8 Oct 2001 06:10:54 +0000 (06:10 +0000)
pear/PEAR/Common.php

index a93631877b2219a10dff931ab0ebc05549495cf0..2c963cb5cf3c595c3443b87226e56fd7ac63a542 100644 (file)
@@ -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)