summaryrefslogtreecommitdiffstats
path: root/lib/helper.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/helper.php')
-rw-r--r--lib/helper.php30
1 files changed, 30 insertions, 0 deletions
diff --git a/lib/helper.php b/lib/helper.php
index ccceb58cd4c..b5e2b8a0d4e 100644
--- a/lib/helper.php
+++ b/lib/helper.php
@@ -525,6 +525,26 @@ class OC_Helper {
}
/**
+ * create a temporary file with an unique filename. It will not be deleted
+ * automatically
+ * @param string $postfix
+ * @return string
+ *
+ */
+ public static function tmpFileNoClean($postfix='') {
+ $tmpDirNoClean=get_temp_dir().'/oc-noclean/';
+ if (!file_exists($tmpDirNoClean) || !is_dir($tmpDirNoClean)) {
+ if (file_exists($tmpDirNoClean))
+ unlink($tmpDirNoClean);
+ mkdir($tmpDirNoClean);
+ }
+ $file=$tmpDirNoClean.md5(time().rand()).$postfix;
+ $fh=fopen($file,'w');
+ fclose($fh);
+ return $file;
+ }
+
+ /**
* create a temporary folder with an unique filename
* @return string
*
@@ -560,6 +580,16 @@ class OC_Helper {
}
/**
+ * remove all files created by self::tmpFileNoClean
+ */
+ public static function cleanTmpNoClean() {
+ $tmpDirNoCleanFile=get_temp_dir().'/oc-noclean/';
+ if(file_exists($tmpDirNoCleanFile)) {
+ self::rmdirr($tmpDirNoCleanFile);
+ }
+ }
+
+ /**
* Adds a suffix to the name in case the file exists
*
* @param $path