/** * 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; }
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); }