diff options
author | Robin Appelman <icewind@owncloud.com> | 2012-11-18 14:07:52 +0100 |
---|---|---|
committer | Robin Appelman <icewind@owncloud.com> | 2012-11-18 14:07:52 +0100 |
commit | a922eb756eeb5a301772361c22b0d7f40b1f1cb0 (patch) | |
tree | ae27f291902989b5fe5c044499a9fb8c16a1cb4d /lib/helper.php | |
parent | 3358bface5c20aeb4ad41dc1edffb895bc24af71 (diff) | |
parent | ea80a8b9e3adb4fb091d0d5c80280de683b7b1a3 (diff) | |
download | nextcloud-server-a922eb756eeb5a301772361c22b0d7f40b1f1cb0.tar.gz nextcloud-server-a922eb756eeb5a301772361c22b0d7f40b1f1cb0.zip |
merge master into filesystem
Diffstat (limited to 'lib/helper.php')
-rw-r--r-- | lib/helper.php | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/lib/helper.php b/lib/helper.php index a7fa7be8738..2b63778024d 100644 --- a/lib/helper.php +++ b/lib/helper.php @@ -525,6 +525,27 @@ 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 +581,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 |