Esempio n. 1
0
 public function tearDown()
 {
     if ($this->instance) {
         OCP\Files::rmdirr($this->instance->constructUrl(''));
     }
 }
Esempio n. 2
0
 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);
 }
Esempio n. 3
0
 /**
  * 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;
 }
Esempio n. 4
0
<?php

//update from OC 3
//try to remove remaining files.
//Give a warning if not possible
$filesToRemove = array('ajax', 'appinfo', 'css', 'js', 'l10n', 'templates', 'admin.php', 'download.php', 'index.php', 'settings.php');
foreach ($filesToRemove as $file) {
    $filepath = OC::$SERVERROOT . '/files/' . $file;
    if (!file_exists($filepath)) {
        continue;
    }
    $success = OCP\Files::rmdirr($filepath);
    if ($success === false) {
        //probably not sufficient privileges, give up and give a message.
        OCP\Util::writeLog('files', 'Could not clean /files/ directory. Please remove everything except webdav.php from ' . OC::$SERVERROOT . '/files/', OCP\Util::ERROR);
        break;
    }
}