| @@ 402-416 (lines=15) @@ | ||
| 399 | case 'x': |
|
| 400 | case 'x+': |
|
| 401 | case 'c': |
|
| 402 | case 'c+': |
|
| 403 | if (strrpos($path, '.') !== false) { |
|
| 404 | $ext = substr($path, strrpos($path, '.')); |
|
| 405 | } else { |
|
| 406 | $ext = ''; |
|
| 407 | } |
|
| 408 | $tmpFile = \OCP\Files::tmpFile($ext); |
|
| 409 | \OC\Files\Stream\Close::registerCallback($tmpFile, [$this, 'writeBack']); |
|
| 410 | if ($this->file_exists($path)) { |
|
| 411 | $source = $this->fopen($path, 'r'); |
|
| 412 | file_put_contents($tmpFile, $source); |
|
| 413 | } |
|
| 414 | self::$tmpFiles[$tmpFile] = $path; |
|
| 415 | ||
| 416 | return fopen('close://' . $tmpFile, $mode); |
|
| 417 | } |
|
| 418 | return false; |
|
| 419 | } |
|
| @@ 121-134 (lines=14) @@ | ||
| 118 | case 'x': |
|
| 119 | case 'x+': |
|
| 120 | case 'c': |
|
| 121 | case 'c+': |
|
| 122 | //emulate these |
|
| 123 | if (strrpos($path, '.')!==false) { |
|
| 124 | $ext=substr($path, strrpos($path, '.')); |
|
| 125 | } else { |
|
| 126 | $ext=''; |
|
| 127 | } |
|
| 128 | $tmpFile=\OCP\Files::tmpFile($ext); |
|
| 129 | \OC\Files\Stream\Close::registerCallback($tmpFile, [$this, 'writeBack']); |
|
| 130 | if ($this->file_exists($path)) { |
|
| 131 | $this->getFile($path, $tmpFile); |
|
| 132 | } |
|
| 133 | self::$tempFiles[$tmpFile]=$path; |
|
| 134 | return fopen('close://'.$tmpFile, $mode); |
|
| 135 | } |
|
| 136 | return false; |
|
| 137 | } |
|
| @@ 287-301 (lines=15) @@ | ||
| 284 | case 'x': |
|
| 285 | case 'x+': |
|
| 286 | case 'c': |
|
| 287 | case 'c+': |
|
| 288 | if (strrpos($path, '.') !== false) { |
|
| 289 | $ext = substr($path, strrpos($path, '.')); |
|
| 290 | } else { |
|
| 291 | $ext = ''; |
|
| 292 | } |
|
| 293 | $tmpFile = \OC::$server->getTempManager()->getTemporaryFile($ext); |
|
| 294 | \OC\Files\Stream\Close::registerCallback($tmpFile, [$this, 'writeBack']); |
|
| 295 | if ($this->file_exists($path)) { |
|
| 296 | $source = $this->fopen($path, 'r'); |
|
| 297 | file_put_contents($tmpFile, $source); |
|
| 298 | } |
|
| 299 | self::$tmpFiles[$tmpFile] = $path; |
|
| 300 | ||
| 301 | return fopen('close://' . $tmpFile, $mode); |
|
| 302 | } |
|
| 303 | return false; |
|
| 304 | } |
|