} else {
$ext = '';
}
- $tmpFile = \OC_Helper::tmpFile($ext);
+ $tmpFile = \OC::$server->getTempManager()->getTemporaryFile($ext);
\OC\Files\Stream\Close::registerCallback($tmpFile, array($this, 'writeBack'));
if ($this->file_exists($path)) {
$source = $this->fopen($path, 'r');
} else {
$extension = '';
}
- $tmpFile = \OC_Helper::tmpFile($extension);
+ $tmpFile = \OC::$server->getTempManager()->getTemporaryFile($extension);
$target = fopen($tmpFile, 'w');
\OC_Helper::streamCopy($source, $target);
fclose($target);
$finfo = finfo_open(FILEINFO_MIME);
return finfo_buffer($finfo, $data);
} else {
- $tmpFile = \OC_Helper::tmpFile();
+ $tmpFile = \OC::$server->getTempManager()->getTemporaryFile();
$fh = fopen($tmpFile, 'wb');
fwrite($fh, $data, 8024);
fclose($fh);
$source = $this->fopen($path, 'r');
if ($source) {
$extension = pathinfo($path, PATHINFO_EXTENSION);
- $tmpFile = \OC_Helper::tmpFile($extension);
+ $tmpFile = \OC::$server->getTempManager()->getTemporaryFile($extension);
file_put_contents($tmpFile, $source);
return $tmpFile;
} else {
return array($count, $result);
}
- /**
- * create a temporary file with an unique filename
- *
- * @param string $postfix
- * @return string
- * @deprecated Use the TempManager instead
- *
- * temporary files are automatically cleaned up after the script is finished
- */
- public static function tmpFile($postfix = '') {
- return \OC::$server->getTempManager()->getTemporaryFile($postfix);
- }
-
/**
* Adds a suffix to the name in case the file exists
*
//download the file if necessary
if($data['source']=='http') {
$pathInfo = pathinfo($data['href']);
- $path=OC_Helper::tmpFile('.' . $pathInfo['extension']);
+ $path = \OC::$server->getTempManager()->getTemporaryFile('.' . $pathInfo['extension']);
if(!isset($data['href'])) {
throw new \Exception($l->t("No href specified when installing app from http"));
}
if ($useFileDirectly) {
$absPath = $fileview->getLocalFile($path);
} else {
- $absPath = \OC_Helper::tmpFile();
+ $absPath = \OC::$server->getTempManager()->getTemporaryFile();
$handle = $fileview->fopen($path, 'rb');
* @return bool|\OCP\IImage
*/
private function generateThumbNail($maxX, $maxY, $absPath, $second) {
- $tmpPath = \OC_Helper::tmpFile();
+ $tmpPath = \OC::$server->getTempManager()->getTemporaryFile();
if (self::$avconvBinary) {
$cmd = self::$avconvBinary . ' -an -y -ss ' . escapeshellarg($second) .
\OC\Files\Filesystem::mkdir('/bar');
// \OC\Files\Filesystem::file_put_contents('/bar//foo', 'foo');
- $tmpFile = \OC_Helper::tmpFile();
+ $tmpFile = \OC::$server->getTempManager()->getTemporaryFile();
file_put_contents($tmpFile, 'foo');
$fh = fopen($tmpFile, 'r');
// \OC\Files\Filesystem::file_put_contents('/bar//foo', $fh);
$pathOfTestApp .= '/../data/';
$pathOfTestApp .= 'testapp.zip';
- $tmp = OC_Helper::tmpFile('.zip');
+ $tmp = \OC::$server->getTempManager()->getTemporaryFile('.zip');
OC_Helper::copyr($pathOfTestApp, $tmp);
$data = array(
$pathOfOldTestApp .= '/../data/';
$pathOfOldTestApp .= 'testapp.zip';
- $oldTmp = OC_Helper::tmpFile('.zip');
+ $oldTmp = \OC::$server->getTempManager()->getTemporaryFile('.zip');
OC_Helper::copyr($pathOfOldTestApp, $oldTmp);
$oldData = array(
$pathOfNewTestApp .= '/../data/';
$pathOfNewTestApp .= 'testapp2.zip';
- $newTmp = OC_Helper::tmpFile('.zip');
+ $newTmp = \OC::$server->getTempManager()->getTemporaryFile('.zip');
OC_Helper::copyr($pathOfNewTestApp, $newTmp);
$newData = array(
public function testCloseStream() {
//ensure all basic stream stuff works
$sourceFile = OC::$SERVERROOT . '/tests/data/lorem.txt';
- $tmpFile = OC_Helper::TmpFile('.txt');
+ $tmpFile = \OC::$server->getTempManager()->getTemporaryFile('.txt');
$file = 'close://' . $tmpFile;
$this->assertTrue(file_exists($file));
file_put_contents($file, file_get_contents($sourceFile));
$this->assertFalse(file_exists($file));
//test callback
- $tmpFile = OC_Helper::TmpFile('.txt');
+ $tmpFile = \OC::$server->getTempManager()->getTemporaryFile('.txt');
$file = 'close://' . $tmpFile;
$actual = false;
$callback = function($path) use (&$actual) { $actual = $path; };