當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Files::tmpFolder方法代碼示例

本文整理匯總了PHP中OCP\Files::tmpFolder方法的典型用法代碼示例。如果您正苦於以下問題:PHP Files::tmpFolder方法的具體用法?PHP Files::tmpFolder怎麽用?PHP Files::tmpFolder使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在OCP\Files的用法示例。


在下文中一共展示了Files::tmpFolder方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: 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

示例2: 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

示例3: remove

 /**
  * remove a file or folder from the archive
  *
  * @param string $path
  * @return bool
  */
 function remove($path)
 {
     if (!$this->fileExists($path)) {
         return false;
     }
     $this->fileList = false;
     $this->cachedHeaders = false;
     //no proper way to delete, extract entire archive, delete file and remake archive
     $tmp = \OCP\Files::tmpFolder();
     $this->tar->extract($tmp);
     \OCP\Files::rmdirr($tmp . $path);
     $this->tar = null;
     unlink($this->path);
     $this->reopen();
     $this->tar->createModify(array($tmp), '', $tmp);
     return true;
 }
開發者ID:GitHubUser4234,項目名稱:core,代碼行數:23,代碼來源:TAR.php

示例4: testCheckDataDirectoryValidity

 public function testCheckDataDirectoryValidity()
 {
     $dataDir = \OCP\Files::tmpFolder();
     touch($dataDir . '/.ocdata');
     $errors = \OC_Util::checkDataDirectoryValidity($dataDir);
     $this->assertEmpty($errors);
     \OCP\Files::rmdirr($dataDir);
     $dataDir = \OCP\Files::tmpFolder();
     // no touch
     $errors = \OC_Util::checkDataDirectoryValidity($dataDir);
     $this->assertNotEmpty($errors);
     \OCP\Files::rmdirr($dataDir);
     if (!\OC_Util::runningOnWindows()) {
         $errors = \OC_Util::checkDataDirectoryValidity('relative/path');
         $this->assertNotEmpty($errors);
     }
 }
開發者ID:rchicoli,項目名稱:owncloud-core,代碼行數:17,代碼來源:UtilTest.php

示例5: testExtract

 public function testExtract()
 {
     $dir = \OC::$SERVERROOT . '/tests/data';
     $this->instance = $this->getExisting();
     $tmpDir = \OCP\Files::tmpFolder();
     $this->instance->extract($tmpDir);
     $this->assertEquals(true, file_exists($tmpDir . 'lorem.txt'));
     $this->assertEquals(true, file_exists($tmpDir . 'dir/lorem.txt'));
     $this->assertEquals(true, file_exists($tmpDir . 'logo-wide.png'));
     $this->assertEquals(file_get_contents($dir . '/lorem.txt'), file_get_contents($tmpDir . 'lorem.txt'));
     \OCP\Files::rmdirr($tmpDir);
 }
開發者ID:rchicoli,項目名稱:owncloud-core,代碼行數:12,代碼來源:TestBase.php


注:本文中的OCP\Files::tmpFolder方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。