summaryrefslogtreecommitdiffstats
path: root/lib/helper.php
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2012-02-28 11:16:19 +0100
committerRobin Appelman <icewind@owncloud.com>2012-02-28 11:16:19 +0100
commit77b51f03e3495fec8f0ed6489b884b1f13e6157d (patch)
treed52922ab492b00313b4afa7398cf6142ad9fe391 /lib/helper.php
parent76d7ce4b5247a69ae15abddb363bd8893f3bf356 (diff)
downloadnextcloud-server-77b51f03e3495fec8f0ed6489b884b1f13e6157d.tar.gz
nextcloud-server-77b51f03e3495fec8f0ed6489b884b1f13e6157d.zip
add temporary file managment
Diffstat (limited to 'lib/helper.php')
-rw-r--r--lib/helper.php25
1 files changed, 25 insertions, 0 deletions
diff --git a/lib/helper.php b/lib/helper.php
index 1ea0a55f469..3c76d38328b 100644
--- a/lib/helper.php
+++ b/lib/helper.php
@@ -26,6 +26,7 @@
*/
class OC_Helper {
private static $mimetypes=array();
+ private static $tmpFiles=array();
/**
* @brief Creates an url
@@ -415,4 +416,28 @@ class OC_Helper {
}
return $count;
}
+
+ /**
+ * create a temporary file with an unique filename
+ * @param string postfix
+ * @return string
+ *
+ * temporary files are automatically cleaned up after the script is finished
+ */
+ public static function tmpFile($postfix=''){
+ $file=tempnam(get_temp_dir(),'OC_TMP_').$postfix;
+ self::$tmpFiles[]=$file;
+ return $file;
+ }
+
+ /**
+ * remove all files created by self::tmpFile
+ */
+ public static function cleanTmp(){
+ foreach(self::$tmpFiles as $file){
+ if(file_exists($file)){
+ unlink($file);
+ }
+ }
+ }
}