public function prependPath($path)
 {
     $this->path = AbstractZipHeader::pathJoin($path, $this->path);
     if (isset($this->extraFieldsArray[AbstractExtraField::HEADER_UNICODE_PATH])) {
         $ef = $this->extraFieldsArray[AbstractExtraField::HEADER_UNICODE_PATH];
         $ef->CRC32 = crc32($this->path);
         $ef->utf8Data = AbstractZipHeader::pathJoin($path, $ef->utf8Data);
     }
 }
Example #2
0
 private function processStream($handle, $subPath = '')
 {
     $pkHeader = null;
     do {
         $curPos = ftell($handle);
         $pkHeader = AbstractZipHeader::seekPKHeader($handle);
         if ($pkHeader === false || feof($handle)) {
             break;
         }
         $pkPos = ftell($handle);
         if ($curPos < $pkPos) {
             $this->_throwException(new HeaderPositionError(array('expected' => $curPos, 'actual' => $pkPos)));
         }
         if ($pkHeader === AbstractZipHeader::ZIP_CENTRAL_FILE_HEADER) {
             $fileEntry = $this->FILES[$this->CDRindex++];
             /* @var $fileEntry ZipFileEntry */
             $fileEntry->parseHeader($handle);
         } else {
             if ($pkHeader === AbstractZipHeader::ZIP_LOCAL_FILE_HEADER) {
                 $fileEntry = new ZipFileEntry($handle);
                 $this->FILES[$this->LFHindex++] = $fileEntry;
                 $fileEntry->prependPath($subPath);
                 $lf = $fileEntry->getLocalHeader();
                 $lfLen = ZipUtils::bin_strlen($lf);
                 $this->zipWrite($lf);
                 fseek($handle, $fileEntry->offset + $fileEntry->dataOffset, SEEK_SET);
                 if (!$fileEntry->isDirectory) {
                     $len = $fileEntry->gzLength;
                     while ($len >= $this->streamChunkSize) {
                         $data = fread($handle, $this->streamChunkSize);
                         $this->zipWrite($data);
                         $len -= $this->streamChunkSize;
                     }
                     $data = fread($handle, $len);
                     $this->zipWrite($data);
                 }
                 $fileEntry->offset = $this->entryOffset;
                 $this->entryOffset += $lfLen + $fileEntry->gzLength;
             } else {
                 if ($pkHeader === AbstractZipHeader::ZIP_END_OF_CENTRAL_DIRECTORY) {
                     fread($handle, 4);
                     $this->eocd = new EndOfCentralDirectory($handle);
                 }
             }
         }
     } while (!feof($handle));
 }