fix temporary file creation

This commit is contained in:
Robin Appelman 2012-02-28 11:32:45 +01:00
parent 7ec1c0703d
commit a76ff563d6
1 changed files with 5 additions and 1 deletions

View File

@ -425,8 +425,11 @@ class OC_Helper {
* temporary files are automatically cleaned up after the script is finished
*/
public static function tmpFile($postfix=''){
$file=tempnam(get_temp_dir(),'OC_TMP_').$postfix;
$file=get_temp_dir().'/'.md5(time().rand()).$postfix;
$fh=fopen($file,'w');
fclose($fh);
self::$tmpFiles[]=$file;
error_log($file);
return $file;
}
@ -436,6 +439,7 @@ class OC_Helper {
public static function cleanTmp(){
foreach(self::$tmpFiles as $file){
if(file_exists($file)){
error_log("clean $file");
unlink($file);
}
}