]> source.dussan.org Git - nextcloud-server.git/commitdiff
add tempory folder utility to OC_Helper
authorRobin Appelman <icewind@owncloud.com>
Wed, 28 Mar 2012 20:30:55 +0000 (22:30 +0200)
committerRobin Appelman <icewind@owncloud.com>
Wed, 28 Mar 2012 21:47:44 +0000 (23:47 +0200)
lib/helper.php

index 66f31d929beca9fb4e275c569ec75f852b08acc6..efff00c2fe6eb23498a8d39946f089cb2f4abcac 100755 (executable)
@@ -432,6 +432,19 @@ class OC_Helper {
                self::$tmpFiles[]=$file;
                return $file;
        }
+
+       /**
+        * create a temporary folder with an unique filename
+        * @return string
+        *
+        * temporary files are automatically cleaned up after the script is finished
+        */
+       public static function tmpFolder(){
+               $path=get_temp_dir().'/'.md5(time().rand());
+               mkdir($path);
+               self::$tmpFiles[]=$path;
+               return $path.'/';
+       }
        
        /**
         * remove all files created by self::tmpFile
@@ -439,7 +452,7 @@ class OC_Helper {
        public static function cleanTmp(){
                foreach(self::$tmpFiles as $file){
                        if(file_exists($file)){
-                               unlink($file);
+                               self::rmdirr($file);
                        }
                }
        }