本文整理汇总了PHP中OCP\Files::rmdirr方法的典型用法代码示例。如果您正苦于以下问题:PHP Files::rmdirr方法的具体用法?PHP Files::rmdirr怎么用?PHP Files::rmdirr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OCP\Files
的用法示例。
在下文中一共展示了Files::rmdirr方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update
public static function update($version, $backupBase)
{
if (!is_dir($backupBase)) {
throw new \Exception("Backup directory {$backupBase} is not found");
}
set_include_path($backupBase . PATH_SEPARATOR . $backupBase . '/core/lib' . PATH_SEPARATOR . $backupBase . '/core/config' . PATH_SEPARATOR . $backupBase . '/3rdparty' . PATH_SEPARATOR . $backupBase . '/apps' . PATH_SEPARATOR . get_include_path());
$tempDir = self::getTempDir();
Helper::mkdir($tempDir, true);
$installed = Helper::getDirectories();
$sources = Helper::getSources($version);
try {
$thirdPartyUpdater = new Location_3rdparty($installed[Helper::THIRDPARTY_DIRNAME], $sources[Helper::THIRDPARTY_DIRNAME]);
$thirdPartyUpdater->update($tempDir . '/' . Helper::THIRDPARTY_DIRNAME);
self::$processed[] = $thirdPartyUpdater;
$coreUpdater = new Location_Core($installed[Helper::CORE_DIRNAME], $sources[Helper::CORE_DIRNAME]);
$coreUpdater->update($tempDir . '/' . Helper::CORE_DIRNAME);
self::$processed[] = $coreUpdater;
$appsUpdater = new Location_Apps('', $sources[Helper::APP_DIRNAME]);
$appsUpdater->update($tempDir . '/' . Helper::APP_DIRNAME);
self::$processed[] = $appsUpdater;
} catch (\Exception $e) {
self::rollBack();
self::cleanUp();
throw $e;
}
// zip backup
$zip = new \ZipArchive();
if ($zip->open($backupBase . ".zip", \ZIPARCHIVE::CREATE) === true) {
Helper::addDirectoryToZip($zip, $backupBase, $backupBase);
$zip->close();
\OCP\Files::rmdirr($backupBase);
}
return true;
}
示例2: tearDown
protected function tearDown()
{
if ($this->instance) {
\OCP\Files::rmdirr($this->instance->constructUrl(''));
}
parent::tearDown();
}
示例3: update
public static function update($version, $backupBase)
{
if (!is_dir($backupBase)) {
throw new \Exception("Backup directory {$backupBase} is not found");
}
// Switch include paths to backup
$pathsArray = explode(PATH_SEPARATOR, get_include_path());
$pathsTranslated = [];
foreach ($pathsArray as $path) {
//Update all 3rdparty paths
if (preg_match('|^' . preg_quote(\OC::$THIRDPARTYROOT . '/3rdparty') . '|', $path)) {
$pathsTranslated[] = preg_replace('|^' . preg_quote(\OC::$THIRDPARTYROOT . '/3rdparty') . '|', $backupBase . '/3rdparty', $path);
continue;
}
// Update all OC webroot paths
$pathsTranslated[] = preg_replace('|^' . preg_quote(\OC::$SERVERROOT) . '|', $backupBase, $path);
}
set_include_path(implode(PATH_SEPARATOR, $pathsTranslated));
$tempDir = self::getTempDir();
Helper::mkdir($tempDir, true);
$installed = Helper::getDirectories();
$sources = Helper::getSources($version);
try {
$thirdPartyUpdater = new \OCA\Updater\Location\Thirdparty($installed[Helper::THIRDPARTY_DIRNAME], $sources[Helper::THIRDPARTY_DIRNAME]);
$thirdPartyUpdater->update($tempDir . '/' . Helper::THIRDPARTY_DIRNAME);
self::$processed[] = $thirdPartyUpdater;
$coreUpdater = new \OCA\Updater\Location\Core($installed[Helper::CORE_DIRNAME], $sources[Helper::CORE_DIRNAME]);
$coreUpdater->update($tempDir . '/' . Helper::CORE_DIRNAME);
self::$processed[] = $coreUpdater;
$appsUpdater = new \OCA\Updater\Location\Apps('', $sources[Helper::APP_DIRNAME]);
$appsUpdater->update($tempDir . '/' . Helper::APP_DIRNAME);
self::$processed[] = $appsUpdater;
} catch (\Exception $e) {
self::rollBack();
self::cleanUp();
throw $e;
}
// zip backup
$zip = new \ZipArchive();
if ($zip->open($backupBase . ".zip", \ZIPARCHIVE::CREATE) === true) {
Helper::addDirectoryToZip($zip, $backupBase);
$zip->close();
\OCP\Files::rmdirr($backupBase);
}
return true;
}
示例4: 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;
}
示例5: tearDown
public function tearDown()
{
if ($this->instance) {
\OCP\Files::rmdirr($this->instance->constructUrl(''));
}
}
示例6: 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);
}
}
示例7: 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);
}