当前位置: 首页>>代码示例>>PHP>>正文


PHP Files::tmpFile方法代码示例

本文整理汇总了PHP中OCP\Files::tmpFile方法的典型用法代码示例。如果您正苦于以下问题:PHP Files::tmpFile方法的具体用法?PHP Files::tmpFile怎么用?PHP Files::tmpFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OCP\Files的用法示例。


在下文中一共展示了Files::tmpFile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testContent

 public function testContent()
 {
     $this->instance = $this->getExisting();
     $dir = \OC::$SERVERROOT . '/tests/data';
     $textFile = $dir . '/lorem.txt';
     $this->assertEquals(file_get_contents($textFile), $this->instance->getFile('lorem.txt'));
     $tmpFile = \OCP\Files::tmpFile('.txt');
     $this->instance->extractFile('lorem.txt', $tmpFile);
     $this->assertEquals(file_get_contents($textFile), file_get_contents($tmpFile));
 }
开发者ID:rchicoli,项目名称:owncloud-core,代码行数:10,代码来源:TestBase.php

示例2: convertLocal

 /**
  * convert via openOffice hosted on the same server
  * @param string $input
  * @param string $targetFilter
  * @param string $targetExtension
  * @return string
  */
 protected static function convertLocal($input, $targetFilter, $targetExtension)
 {
     $infile = \OCP\Files::tmpFile();
     $outdir = \OCP\Files::tmpFolder();
     $cmd = Helper::findOpenOffice();
     $params = ' --headless --convert-to ' . $targetFilter . ' --outdir ' . escapeshellarg($outdir) . ' --writer ' . escapeshellarg($infile) . ' -env:UserInstallation=file://' . escapeshellarg(get_temp_dir() . '/owncloud-' . \OC_Util::getInstanceId() . '/');
     file_put_contents($infile, $input);
     shell_exec($cmd . $params);
     $output = file_get_contents($outdir . '/' . basename($infile) . '.' . $targetExtension);
     return $output;
 }
开发者ID:Ebimedia,项目名称:owncloud,代码行数:18,代码来源:converter.php

示例3: getPackage

 public static function getPackage($url, $version)
 {
     self::$package = \OCP\Files::tmpFile();
     if (!self::$package) {
         throw new \Exception('Unable to create a temporary file');
     }
     try {
         if (self::fetch($url) === false) {
             throw new \Exception("Error storing package content");
         }
         if (preg_match('/\\.zip$/i', $url)) {
             rename(self::$package, self::$package . '.zip');
             self::$package .= '.zip';
         } elseif (preg_match('/(\\.tgz|\\.tar\\.gz)$/i', $url)) {
             rename(self::$package, self::$package . '.tgz');
             self::$package .= '.tgz';
         } elseif (preg_match('/\\.tar\\.bz2$/i', $url)) {
             rename(self::$package, self::$package . '.tar.bz2');
             self::$package .= '.tar.bz2';
         } else {
             throw new \Exception('Unable to extract package');
         }
         $extractDir = self::getPackageDir($version);
         Helper::mkdir($extractDir, true);
         $archive = \OC_Archive::open(self::$package);
         if (!$archive || !$archive->extract($extractDir)) {
             throw new \Exception(self::$package . " extraction error");
         }
     } catch (\Exception $e) {
         App::log('Retrieving ' . $url);
         self::cleanUp($version);
         throw $e;
     }
     Helper::removeIfExists(self::$package);
     //  Prepare extracted data
     //  to have '3rdparty', 'apps' and 'core' subdirectories
     $sources = Helper::getSources($version);
     $baseDir = $extractDir . '/' . self::PACKAGE_ROOT;
     rename($baseDir . '/' . Helper::THIRDPARTY_DIRNAME, $sources[Helper::THIRDPARTY_DIRNAME]);
     rename($baseDir . '/' . Helper::APP_DIRNAME, $sources[Helper::APP_DIRNAME]);
     rename($baseDir, $sources[Helper::CORE_DIRNAME]);
 }
开发者ID:CDN-Sparks,项目名称:owncloud,代码行数:42,代码来源:downloader.php

示例4: testConversion

 public static function testConversion()
 {
     $targetFilter = 'odt:writer8';
     $targetExtension = 'odt';
     $input = file_get_contents(dirname(__DIR__) . self::TEST_DOC_PATH);
     $infile = \OCP\Files::tmpFile();
     $outdir = \OCP\Files::tmpFolder();
     $outfile = $outdir . '/' . basename($infile) . '.' . $targetExtension;
     $cmd = Helper::findOpenOffice();
     $params = ' --headless --convert-to ' . escapeshellarg($targetFilter) . ' --outdir ' . escapeshellarg($outdir) . ' --writer ' . escapeshellarg($infile) . ' -env:UserInstallation=file://' . escapeshellarg(get_temp_dir() . '/owncloud-' . \OC_Util::getInstanceId() . '/') . ' 2>&1';
     file_put_contents($infile, $input);
     $result = shell_exec($cmd . $params);
     $exists = file_exists($outfile);
     if (!$exists) {
         Helper::warnLog('Conversion test failed. Raw output:' . $result);
         return false;
     } else {
         unlink($outfile);
     }
     return true;
 }
开发者ID:Ebimedia,项目名称:owncloud,代码行数:21,代码来源:config.php

示例5: fopen

 public function fopen($path, $mode)
 {
     switch ($mode) {
         case 'r':
         case 'rb':
         case 'w':
         case 'wb':
         case 'a':
         case 'ab':
             //these are supported by the wrapper
             $context = stream_context_create(array('ftp' => array('overwrite' => true)));
             return fopen($this->constructUrl($path), $mode, false, $context);
         case 'r+':
         case 'w+':
         case 'wb+':
         case 'a+':
         case 'x':
         case 'x+':
         case 'c':
         case 'c+':
             //emulate these
             if (strrpos($path, '.') !== false) {
                 $ext = substr($path, strrpos($path, '.'));
             } else {
                 $ext = '';
             }
             $tmpFile = \OCP\Files::tmpFile($ext);
             \OC\Files\Stream\Close::registerCallback($tmpFile, array($this, 'writeBack'));
             if ($this->file_exists($path)) {
                 $this->getFile($path, $tmpFile);
             }
             self::$tempFiles[$tmpFile] = $path;
             return fopen('close://' . $tmpFile, $mode);
     }
     return false;
 }
开发者ID:CDN-Sparks,项目名称:owncloud,代码行数:36,代码来源:ftp.php

示例6: getNew

 protected function getNew()
 {
     return new ZIP(\OCP\Files::tmpFile('.zip'));
 }
开发者ID:rchicoli,项目名称:owncloud-core,代码行数:4,代码来源:ZIPTest.php

示例7: getStream

 /**
  * get a file handler
  *
  * @param string $path
  * @param string $mode
  * @return resource
  */
 function getStream($path, $mode)
 {
     if (strrpos($path, '.') !== false) {
         $ext = substr($path, strrpos($path, '.'));
     } else {
         $ext = '';
     }
     $tmpFile = \OCP\Files::tmpFile($ext);
     if ($this->fileExists($path)) {
         $this->extractFile($path, $tmpFile);
     } elseif ($mode == 'r' or $mode == 'rb') {
         return false;
     }
     if ($mode == 'r' or $mode == 'rb') {
         return fopen($tmpFile, $mode);
     } else {
         \OC\Files\Stream\Close::registerCallback($tmpFile, array($this, 'writeBack'));
         self::$tempFiles[$tmpFile] = $path;
         return fopen('close://' . $tmpFile, $mode);
     }
 }
开发者ID:GitHubUser4234,项目名称:core,代码行数:28,代码来源:TAR.php

示例8: fopen

 public function fopen($path, $mode)
 {
     $path = $this->normalizePath($path);
     switch ($mode) {
         case 'r':
         case 'rb':
             $tmpFile = \OCP\Files::tmpFile();
             self::$tmpFiles[$tmpFile] = $path;
             try {
                 $this->getConnection()->getObject(array('Bucket' => $this->bucket, 'Key' => $path, 'SaveAs' => $tmpFile));
             } catch (S3Exception $e) {
                 \OCP\Util::logException('files_external', $e);
                 return false;
             }
             return fopen($tmpFile, 'r');
         case 'w':
         case 'wb':
         case 'a':
         case 'ab':
         case 'r+':
         case 'w+':
         case 'wb+':
         case 'a+':
         case 'x':
         case 'x+':
         case 'c':
         case 'c+':
             if (strrpos($path, '.') !== false) {
                 $ext = substr($path, strrpos($path, '.'));
             } else {
                 $ext = '';
             }
             $tmpFile = \OCP\Files::tmpFile($ext);
             \OC\Files\Stream\Close::registerCallback($tmpFile, array($this, 'writeBack'));
             if ($this->file_exists($path)) {
                 $source = $this->fopen($path, 'r');
                 file_put_contents($tmpFile, $source);
             }
             self::$tmpFiles[$tmpFile] = $path;
             return fopen('close://' . $tmpFile, $mode);
     }
     return false;
 }
开发者ID:stweil,项目名称:owncloud-core,代码行数:43,代码来源:amazons3.php

示例9: fopen

 public function fopen($path, $mode)
 {
     $path = $this->normalizePath($path);
     switch ($mode) {
         case 'r':
         case 'rb':
             $tmpFile = \OCP\Files::tmpFile();
             self::$tmpFiles[$tmpFile] = $path;
             try {
                 $object = $this->getContainer()->getObject($path);
             } catch (ClientErrorResponseException $e) {
                 \OCP\Util::writeLog('files_external', $e->getMessage(), \OCP\Util::ERROR);
                 return false;
             } catch (Exception\ObjectNotFoundException $e) {
                 \OCP\Util::writeLog('files_external', $e->getMessage(), \OCP\Util::ERROR);
                 return false;
             }
             try {
                 $objectContent = $object->getContent();
                 $objectContent->rewind();
                 $stream = $objectContent->getStream();
                 file_put_contents($tmpFile, $stream);
             } catch (Exceptions\IOError $e) {
                 \OCP\Util::writeLog('files_external', $e->getMessage(), \OCP\Util::ERROR);
                 return false;
             }
             return fopen($tmpFile, 'r');
         case 'w':
         case 'wb':
         case 'a':
         case 'ab':
         case 'r+':
         case 'w+':
         case 'wb+':
         case 'a+':
         case 'x':
         case 'x+':
         case 'c':
         case 'c+':
             if (strrpos($path, '.') !== false) {
                 $ext = substr($path, strrpos($path, '.'));
             } else {
                 $ext = '';
             }
             $tmpFile = \OCP\Files::tmpFile($ext);
             \OC\Files\Stream\Close::registerCallback($tmpFile, array($this, 'writeBack'));
             // Fetch existing file if required
             if ($mode[0] !== 'w' && $this->file_exists($path)) {
                 if ($mode[0] === 'x') {
                     // File cannot already exist
                     return false;
                 }
                 $source = $this->fopen($path, 'r');
                 file_put_contents($tmpFile, $source);
                 // Seek to end if required
                 if ($mode[0] === 'a') {
                     fseek($tmpFile, 0, SEEK_END);
                 }
             }
             self::$tmpFiles[$tmpFile] = $path;
             return fopen('close://' . $tmpFile, $mode);
     }
 }
开发者ID:kenwi,项目名称:core,代码行数:63,代码来源:swift.php

示例10: fopen

	/**
	 * {@inheritdoc}
	 */
	public function fopen($path, $mode) {
		$fullPath = $this->buildPath($path);
		$useExisting = true;
		switch ($mode) {
			case 'r':
			case 'rb':
				try {
					return $this->flysystem->readStream($fullPath);
				} catch (FileNotFoundException $e) {
					return false;
				}
			case 'w':
			case 'w+':
			case 'wb':
			case 'wb+':
				$useExisting = false;
			case 'a':
			case 'ab':
			case 'r+':
			case 'a+':
			case 'x':
			case 'x+':
			case 'c':
			case 'c+':
				//emulate these
				if ($useExisting and $this->file_exists($path)) {
					if (!$this->isUpdatable($path)) {
						return false;
					}
					$tmpFile = $this->getCachedFile($path);
				} else {
					if (!$this->isCreatable(dirname($path))) {
						return false;
					}
					$tmpFile = \OCP\Files::tmpFile();
				}
				$source = fopen($tmpFile, $mode);
				return CallbackWrapper::wrap($source, null, null, function () use ($tmpFile, $fullPath) {
					$this->flysystem->putStream($fullPath, fopen($tmpFile, 'r'));
					unlink($tmpFile);
				});
		}
		return false;
	}
开发者ID:ninjasilicon,项目名称:core,代码行数:47,代码来源:flysystem.php

示例11: setUp

 protected function setUp()
 {
     parent::setUp();
     $this->tmpFile = \OCP\Files::tmpFile('.tar.gz');
     $this->instance = new \OC\Files\Storage\Archive(array('archive' => $this->tmpFile));
 }
开发者ID:DOM-Digital-Online-Media,项目名称:apps,代码行数:6,代码来源:storage.php

示例12: fopen

 public function fopen($path, $mode)
 {
     $path = $this->root . $path;
     switch ($mode) {
         case 'r':
         case 'rb':
             $tmpFile = \OCP\Files::tmpFile();
             try {
                 $data = $this->dropbox->getFile($path);
                 file_put_contents($tmpFile, $data);
                 return fopen($tmpFile, 'r');
             } catch (\Exception $exception) {
                 \OCP\Util::writeLog('files_external', $exception->getMessage(), \OCP\Util::ERROR);
                 return false;
             }
         case 'w':
         case 'wb':
         case 'a':
         case 'ab':
         case 'r+':
         case 'w+':
         case 'wb+':
         case 'a+':
         case 'x':
         case 'x+':
         case 'c':
         case 'c+':
             if (strrpos($path, '.') !== false) {
                 $ext = substr($path, strrpos($path, '.'));
             } else {
                 $ext = '';
             }
             $tmpFile = \OCP\Files::tmpFile($ext);
             \OC\Files\Stream\Close::registerCallback($tmpFile, array($this, 'writeBack'));
             if ($this->file_exists($path)) {
                 $source = $this->fopen($path, 'r');
                 file_put_contents($tmpFile, $source);
             }
             self::$tempFiles[$tmpFile] = $path;
             return fopen('close://' . $tmpFile, $mode);
     }
     return false;
 }
开发者ID:evanjt,项目名称:core,代码行数:43,代码来源:dropbox.php

示例13: fopen

 public function fopen($path, $mode)
 {
     $path = $this->normalizePath($path);
     switch ($mode) {
         case 'r':
         case 'rb':
             try {
                 $c = $this->getContainer();
                 $streamFactory = new \Guzzle\Stream\PhpStreamRequestFactory();
                 $streamInterface = $streamFactory->fromRequest($c->getClient()->get($c->getUrl($path)));
                 $streamInterface->rewind();
                 $stream = $streamInterface->getStream();
                 stream_context_set_option($stream, 'swift', 'content', $streamInterface);
                 if (!strrpos($streamInterface->getMetaData('wrapper_data')[0], '404 Not Found')) {
                     return $stream;
                 }
                 return false;
             } catch (\Guzzle\Http\Exception\BadResponseException $e) {
                 \OCP\Util::writeLog('files_external', $e->getMessage(), \OCP\Util::ERROR);
                 return false;
             }
         case 'w':
         case 'wb':
         case 'a':
         case 'ab':
         case 'r+':
         case 'w+':
         case 'wb+':
         case 'a+':
         case 'x':
         case 'x+':
         case 'c':
         case 'c+':
             if (strrpos($path, '.') !== false) {
                 $ext = substr($path, strrpos($path, '.'));
             } else {
                 $ext = '';
             }
             $tmpFile = \OCP\Files::tmpFile($ext);
             \OC\Files\Stream\Close::registerCallback($tmpFile, array($this, 'writeBack'));
             // Fetch existing file if required
             if ($mode[0] !== 'w' && $this->file_exists($path)) {
                 if ($mode[0] === 'x') {
                     // File cannot already exist
                     return false;
                 }
                 $source = $this->fopen($path, 'r');
                 file_put_contents($tmpFile, $source);
                 // Seek to end if required
                 if ($mode[0] === 'a') {
                     fseek($tmpFile, 0, SEEK_END);
                 }
             }
             self::$tmpFiles[$tmpFile] = $path;
             return fopen('close://' . $tmpFile, $mode);
     }
 }
开发者ID:rchicoli,项目名称:owncloud-core,代码行数:57,代码来源:Swift.php

示例14: getStream

 /**
  * get a file handler
  * @param string $path
  * @param string $mode
  * @return resource
  */
 function getStream($path, $mode)
 {
     if ($mode == 'r' or $mode == 'rb') {
         return $this->zip->getStream($path);
     } else {
         //since we can't directly get a writable stream,
         //make a temp copy of the file and put it back
         //in the archive when the stream is closed
         if (strrpos($path, '.') !== false) {
             $ext = substr($path, strrpos($path, '.'));
         } else {
             $ext = '';
         }
         $tmpFile = \OCP\Files::tmpFile($ext);
         \OC\Files\Stream\Close::registerCallback($tmpFile, array($this, 'writeBack'));
         if ($this->fileExists($path)) {
             $this->extractFile($path, $tmpFile);
         }
         self::$tempFiles[$tmpFile] = $path;
         return fopen('close://' . $tmpFile, $mode);
     }
 }
开发者ID:stweil,项目名称:owncloud-core,代码行数:28,代码来源:ZIP.php

示例15: getNew

 protected function getNew()
 {
     return new TAR(\OCP\Files::tmpFile('.tar.gz'));
 }
开发者ID:rchicoli,项目名称:owncloud-core,代码行数:4,代码来源:TARTest.php


注:本文中的OCP\Files::tmpFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。