本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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);
}
}
示例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);
}