/** * Fetches a ZIP file * * @param string url * @return io.archive.zip.ZipArchiveReader */ protected function zipballOf($url) { $headers = array(); do { Console::write('>> ', $url, ': '); $response = $this->connectionTo($url, $headers)->get(); switch ($response->statusCode()) { case HttpConstants::STATUS_OK: Console::writeLine('Ok'); return ZipFile::open($response->getInputStream()); case HttpConstants::STATUS_FOUND: case HttpConstants::STATUS_SEE_OTHER: Console::writeLine('Redirect'); $headers['Referer'] = $url; $url = this($response->header('Location'), 0); continue; default: Console::writeLine('Error'); throw new IllegalStateException('Unexpected response for ' . $url . ': ' . $response->toString()); } } while (1); // Unreachable }
/** * Returns an archive reader for a given zip file * * @param string package * @param string name * @return io.archive.zip.ZipArchiveReader */ protected function archiveReaderFor($package, $name) { return ZipFile::open($this->getClass()->getPackage()->getPackage($package)->getResourceAsStream($name . '.zip')->getInputStream()); }
public function using_unicode_names() { $this->out = new MemoryOutputStream(); $this->fixture = ZipFile::create($this->out)->usingUnicodeNames(); $this->fixture->addFile(new ZipFileEntry('関連事業調査.txt'))->out()->write('File contents'); $this->fixture->close(); $this->assertEquals(['関連事業調査.txt' => 'File contents'], $this->entriesWithContentIn($this->out, 'secret')); }
public function zipfile_open() { $this->assertInstanceOf(ZipArchiveReader::class, ZipFile::open(new MemoryInputStream('PK...'))); }