Lines Matching refs:this

33      * You can call this function before adding each file to set differen compression levels
45 $this->complevel = $level;
56 $this->file = $file;
57 $this->fh = @fopen($this->file, 'rb');
58 if (!$this->fh) {
59 throw new ArchiveIOException('Could not open file for reading: '.$this->file);
61 $this->closed = false;
79 foreach ($this->yieldContents() as $fileinfo) {
96 if ($this->closed || !$this->file) {
100 $centd = $this->readCentralDir();
102 @rewind($this->fh);
103 @fseek($this->fh, $centd['offset']);
106 yield $this->header2fileinfo($this->readCentralFileHeader());
109 $this->close();
118 * Alternatively a fixed string prefix may be passed in $strip. If the filename matches this prefix,
121 * By default this will extract all files found in the archive. You can restrict the output using the $include
123 * $include is set only files that match this expression will be extracted. Files that match the $exclude
136 if ($this->closed || !$this->file) {
145 $cdir = $this->readCentralDir();
150 @fseek($this->fh, $pos_entry);
151 $header = $this->readCentralFileHeader();
153 $pos_entry = ftell($this->fh); // position of the next file in central file directory
154 fseek($this->fh, $header['offset']); // seek to beginning of file header
155 $header = $this->readFileHeader($header);
156 $fileinfo = $this->header2fileinfo($header);
175 if(is_callable($this->callback)) {
176 call_user_func($this->callback, $fileinfo);
212 $buffer = fread($this->fh, $read_size);
254 if(is_callable($this->callback)) {
255 call_user_func($this->callback, $fileinfo);
259 $this->close();
273 $this->file = $file;
274 $this->memory = '';
275 $this->fh = 0;
277 if ($this->file) {
278 $this->fh = @fopen($this->file, 'wb');
280 if (!$this->fh) {
281 throw new ArchiveIOException('Could not open file for writing: '.$this->file);
284 $this->writeaccess = true;
285 $this->closed = false;
286 $this->ctrl_dir = array();
311 if ($this->closed) {
320 $offset = $this->dataOffset();
325 $this->writebytes($this->makeLocalFileHeader(
331 (bool) $this->complevel
337 $deflate_context = deflate_init(ZLIB_ENCODING_DEFLATE, ['level' => $this->complevel]);
344 if ($this->complevel) {
362 $this->writebytes($c_block);
364 $this->writebytes($block);
374 $csize = $this->complevel ? $csize : $size;
375 $this->writebytesAt($this->makeCrcAndSize(
384 $this->ctrl_dir[] = $this->makeCentralFileRecord(
391 (bool) $this->complevel
394 if(is_callable($this->callback)) {
395 call_user_func($this->callback, $fileinfo);
412 if ($this->closed) {
419 if ($this->complevel) {
420 $data = gzcompress($data, $this->complevel);
424 $offset = $this->dataOffset();
429 $this->writebytes($this->makeLocalFileHeader(
435 (bool) $this->complevel
441 $this->writebytes($data);
446 $this->ctrl_dir[] = $this->makeCentralFileRecord(
453 (bool) $this->complevel
456 if(is_callable($this->callback)) {
457 call_user_func($this->callback, $fileinfo);
464 * After a call to this function no more data can be added to the archive, for
470 if ($this->closed) {
472 } // we did this already
474 if ($this->writeaccess) {
476 $offset = $this->dataOffset();
477 $ctrldir = join('', $this->ctrl_dir);
478 $this->writebytes($ctrldir);
481 $this->writebytes("\x50\x4b\x05\x06"); // end of central dir signature
482 $this->writebytes(pack('v', 0)); // number of this disk
483 $this->writebytes(pack('v', 0)); // number of the disk with the start of the central directory
484 $this->writebytes(pack('v',
485 count($this->ctrl_dir))); // total number of entries in the central directory on this disk
486 $this->writebytes(pack('v', count($this->ctrl_dir))); // total number of entries in the central directory
487 $this->writebytes(pack('V', strlen($ctrldir))); // size of the central directory
488 $this->writebytes(pack('V',
490 $this->writebytes(pack('v', 0)); // .ZIP file comment length
492 $this->ctrl_dir = array();
496 if ($this->file) {
497 fclose($this->fh);
498 $this->file = '';
499 $this->fh = 0;
502 $this->writeaccess = false;
503 $this->closed = true;
514 $this->close();
516 return $this->memory;
530 if (!@file_put_contents($file, $this->getArchive())) {
544 $size = filesize($this->file);
551 @fseek($this->fh, $size - $maximum_size);
552 $pos = ftell($this->fh);
556 $byte = @fread($this->fh, 1);
566 fread($this->fh, 18)
570 $centd['comment'] = fread($this->fh, $data['comment_size']);
592 $binary_data = fread($this->fh, 46);
599 $header['filename'] = fread($this->fh, $header['filename_len']);
605 $header['extra'] = fread($this->fh, $header['extra_len']);
606 $header['extradata'] = $this->parseExtra($header['extra']);
613 $header['comment'] = fread($this->fh, $header['comment_len']);
618 $header['mtime'] = $this->makeUnixTime($header['mdate'], $header['mtime']);
640 $binary_data = fread($this->fh, 30);
646 $header['filename'] = fread($this->fh, $data['filename_len']);
648 $header['extra'] = fread($this->fh, $data['extra_len']);
649 $header['extradata'] = array_merge($header['extradata'], $this->parseExtra($header['extra']));
666 $header['mtime'] = $this->makeUnixTime($data['mdate'], $data['mtime']);
721 $fileinfo->setPath($this->cpToUtf8($header['filename']));
727 $fileinfo->setComment($this->cpToUtf8($header['comment']));
792 if (!$this->file) {
793 $this->memory .= $data;
796 $written = @fwrite($this->fh, $data);
813 if (!$this->file) {
814 $this->memory .= substr_replace($this->memory, $data, $offset);
817 @fseek($this->fh, $offset);
818 $written = @fwrite($this->fh, $data);
819 @fseek($this->fh, 0, SEEK_END);
835 if ($this->file) {
836 return ftell($this->fh);
838 return strlen($this->memory);
845 * DOS timestamps start at 1980-01-01, earlier UNIX stamps will be set to this date
911 $dtime = dechex($this->makeDosTime($ts));
913 list($name, $extra) = $this->encodeFilename($name);
958 $dtime = dechex($this->makeDosTime($ts));
960 list($name, $extra) = $this->encodeFilename($name);
1010 $cp437 = $this->utf8ToCp($original);