From d8e9db207f94d8a46cd8a81caa1b49cd64843259 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Wed, 28 Mar 2012 22:30:55 +0200 Subject: [PATCH] add tempory folder utility to OC_Helper --- lib/helper.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/helper.php b/lib/helper.php index 66f31d929be..efff00c2fe6 100755 --- a/lib/helper.php +++ b/lib/helper.php @@ -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); } } } -- 2.39.5