stat() . */ trait LocalTempFileTrait { /** @var array */ protected array $cachedFiles = []; protected function getCachedFile(string $path): string|false { if (!isset($this->cachedFiles[$path])) { $this->cachedFiles[$path] = $this->toTmpFile($path); } return $this->cachedFiles[$path]; } protected function removeCachedFile(string $path): void { unset($this->cachedFiles[$path]); } protected function toTmpFile(string $path): string|false { //no longer in the storage api, still useful here $source = $this->fopen($path, 'r'); if (!$source) { return false; } if ($pos = strrpos($path, '.')) { $extension = substr($path, $pos); } else { $extension = ''; } $tmpFile = \OC::$server->getTempManager()->getTemporaryFile($extension); $target = fopen($tmpFile, 'w'); \OC_Helper::streamCopy($source, $target); fclose($target); return $tmpFile; } }