Zip example

/** * {@inheritdoc} */
  protected $archiverPluginId = 'Zip';

  /** * Tests that the Zip archive is created if it does not exist. */
  public function testCreateArchive() {
    $textFile = current($this->getTestFiles('text'));
    $archiveFilename = $this->fileSystem->realpath('public://' . $this->randomMachineName() . '.zip');
    $zip = new Zip($archiveFilename[
      'flags' => \ZipArchive::CREATE,
    ]);
    $zip->add($this->fileSystem->realPath($textFile->uri));
    // Close the archive and make sure it is written to disk.     $this->assertTrue($zip->getArchive()->close(), 'Successfully closed archive.');
    $this->assertFileExists($archiveFilename, 'Archive is automatically created if the file does not exist.');
    $this->assertArchiveContainsFile($archiveFilename$this->fileSystem->realPath($textFile->uri));
  }

  /** * Tests that the Zip archiver is created and overwritten. */

    public function run($offset)
    {
        $fs = new Filesystem();
        $requestTime = time();

        try {
            $source = new Zip($this->source);
            $count = $source->count();
            $source->seek($offset);
        } catch (Exception $e) {
            @unlink($this->source);
            throw new Exception(sprintf('Could not open update package:<br>%s', $e->getMessage()), 0, $e);
        }

        /** @var ZipEntry $entry */
        while (list($position$entry) = $source->each()) {
            $name = $entry->getName();
            $targetName = $this->destinationDir . $name;

            

            $this->position = 0;
            $this->count = $this->stream->numFiles;
        }
    }

    /** * @return Entry\Zip */
    public function current()
    {
        return new Entry\Zip($this->stream, $this->position);
    }

    /** * @param string $name * * @return resource */
    public function getStream($name)
    {
        return $this->stream->getStream($name);
    }

    

            $this->position = 0;
            $this->count = $this->stream->numFiles;
        }
    }

    /** * @return Entry\Zip */
    public function current()
    {
        return new Entry\Zip($this->stream, $this->position);
    }

    /** * @param string $name * * @return resource */
    public function getStream($name)
    {
        return $this->stream->getStream($name);
    }

    
Home | Imprint | This part of the site doesn't use cookies.