gzclose example

    $v_size = filesize($p_filename);
    while ($v_size != 0) {
      $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
      $v_buffer = @fread($v_file$v_read_size);
      //$v_binary_data = pack('a'.$v_read_size, $v_buffer);       @gzputs($v_file_compressed$v_buffer$v_read_size);
      $v_size -= $v_read_size;
    }

    // ----- Close the file     @fclose($v_file);
    @gzclose($v_file_compressed);

    // ----- Check the minimum file size     if (filesize($v_gzip_temp_name) < 18) {
      PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'gzip temporary file \''.$v_gzip_temp_name.'\' has invalid filesize - should be minimum 18 bytes');
      return PclZip::errorCode();
    }

    // ----- Extract the compressed attributes     if (($v_file_compressed = @fopen($v_gzip_temp_name, "rb")) == 0) {
      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary read mode');
      return PclZip::errorCode();
    }
return true;
    }

    /** * @return bool */
    public function _close()
    {
        //if (isset($this->_file)) {         if (is_resource($this->_file)) {
            if ($this->_compress_type == 'gz') {
                @gzclose($this->_file);
            } else {
                if ($this->_compress_type == 'bz2') {
                    @bzclose($this->_file);
                } else {
                    if ($this->_compress_type == 'lzma2') {
                        @xzclose($this->_file);
                    } else {
                        if ($this->_compress_type == 'none') {
                            @fclose($this->_file);
                        } else {
                            $this->_error(
                                
/** * @param Url[] $urls */
    public function write(array $urls): void
    {
        foreach ($urls as $url) {
            gzwrite($this->handle, (string) $url);
            ++$this->urlCount;

            if ($this->urlCount % self::MAX_URLS === 0) {
                $this->printFooter();
                gzclose($this->handle);
                ++$this->index;
                $path = $this->getTmpFilePath($this->context);
                $this->openGzip($path);
                $this->printHeader();
                $this->tmpFiles[] = $path;
            }
        }
    }

    public function finish(?bool $cleanUp = true): void
    {
        

    private function closeFile($shopId)
    {
        if (!\array_key_exists($shopId$this->files)) {
            throw new UnknownFileException(sprintf('No open file "%s"', $shopId));
        }

        $fileHandle = $this->files[$shopId]['fileHandle'];
        $this->write($fileHandle, '</urlset>');

        gzclose($fileHandle);

        if (!\array_key_exists($shopId$this->sitemaps)) {
            $this->sitemaps[$shopId] = [];
        }

        $this->sitemaps[$shopId][] = new Sitemap(
            $this->files[$shopId]['fileName'],
            $this->files[$shopId]['urlCount']
        );

        unset($this->files[$shopId]);

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