Lines Matching defs:header
149 // read file header
151 $header = $this->readCentralFileHeader();
152 $header['index'] = $i;
154 fseek($this->fh, $header['offset']); // seek to beginning of file header
155 $header = $this->readFileHeader($header);
156 $fileinfo = $this->header2fileinfo($header);
170 $directory = ($header['folder']) ? $output : dirname($output);
182 if ($header['compression'] == 0) {
194 // prepend compression header
195 if ($header['compression'] != 0) {
199 chr($header['compression']),
209 $size = $header['compressed_size'];
219 if ($header['compression'] != 0) {
220 $binary_data = pack('VV', $header['crc'], $header['size']);
228 if ($header['compression'] != 0) {
239 $size = $header['size'];
324 // write local file header (temporary CRC and size)
334 // we store no encryption header
356 // get rid of the compression header
372 // update the local file header with the computed CRC and size
428 // write local file header
438 // we store no encryption header
584 * Read the next central file header
593 $header = unpack(
598 if ($header['filename_len'] != 0) {
599 $header['filename'] = fread($this->fh, $header['filename_len']);
601 $header['filename'] = '';
604 if ($header['extra_len'] != 0) {
605 $header['extra'] = fread($this->fh, $header['extra_len']);
606 $header['extradata'] = $this->parseExtra($header['extra']);
608 $header['extra'] = '';
609 $header['extradata'] = array();
612 if ($header['comment_len'] != 0) {
613 $header['comment'] = fread($this->fh, $header['comment_len']);
615 $header['comment'] = '';
618 $header['mtime'] = $this->makeUnixTime($header['mdate'], $header['mtime']);
619 $header['stored_filename'] = $header['filename'];
620 $header['status'] = 'ok';
621 if (substr($header['filename'], -1) == '/') {
622 $header['external'] = 0x41FF0010;
624 $header['folder'] = ($header['external'] == 0x41FF0010 || $header['external'] == 16) ? 1 : 0;
626 return $header;
630 * Reads the local file header
632 * This header precedes each individual file inside the zip file. Assumes the current file pointer is pointing at
633 * the right position already. Enhances the given central header with the data found at the local header.
635 * @param array $header the central file header read previously (see above)
638 protected function readFileHeader($header)
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']));
651 $header['extra'] = '';
652 $header['extradata'] = array();
655 $header['compression'] = $data['compression'];
662 $header[$hd] = $data[$hd];
665 $header['flag'] = $data['flag'];
666 $header['mtime'] = $this->makeUnixTime($data['mdate'], $data['mtime']);
668 $header['stored_filename'] = $header['filename'];
669 $header['status'] = "ok";
670 $header['folder'] = ($header['external'] == 0x41FF0010 || $header['external'] == 16) ? 1 : 0;
671 return $header;
677 * @param string $header
680 protected function parseExtra($header)
684 while (strlen($header) !== 0) {
685 $set = unpack('vid/vlen', $header);
686 $header = substr($header, 4);
687 $value = substr($header, 0, $set['len']);
688 $header = substr($header, $set['len']);
704 * Create fileinfo object from header data
706 * @param $header
709 protected function header2fileinfo($header)
712 $fileinfo->setSize($header['size']);
713 $fileinfo->setCompressedSize($header['compressed_size']);
714 $fileinfo->setMtime($header['mtime']);
715 $fileinfo->setComment($header['comment']);
716 $fileinfo->setIsdir($header['external'] == 0x41FF0010 || $header['external'] == 16);
718 if(isset($header['extradata']['utf8path'])) {
719 $fileinfo->setPath($header['extradata']['utf8path']);
721 $fileinfo->setPath($this->cpToUtf8($header['filename']));
724 if(isset($header['extradata']['utf8comment'])) {
725 $fileinfo->setComment($header['extradata']['utf8comment']);
727 $fileinfo->setComment($this->cpToUtf8($header['comment']));
896 * Returns a local file header for the given data
898 * @param int $offset location of the local header
915 $header = "\x50\x4b\x01\x02"; // central file header signature
916 $header .= pack('v', 14); // version made by - VFAT
917 $header .= pack('v', 20); // version needed to extract - 2.0
918 $header .= pack('v', 0); // general purpose flag - no flags set
919 $header .= pack('v', $comp); // compression method - deflate|none
920 $header .= pack(
927 $header .= pack('V', $crc); // crc-32
928 $header .= pack('V', $clen); // compressed size
929 $header .= pack('V', $len); // uncompressed size
930 $header .= pack('v', strlen($name)); // file name length
931 $header .= pack('v', strlen($extra)); // extra field length
932 $header .= pack('v', 0); // file comment length
933 $header .= pack('v', 0); // disk number start
934 $header .= pack('v', 0); // internal file attributes
935 $header .= pack('V', 0); // external file attributes @todo was 0x32!?
936 $header .= pack('V', $offset); // relative offset of local header
937 $header .= $name; // file name
938 $header .= $extra; // extra (utf-8 filename)
940 return $header;
944 * Returns a local file header for the given data
962 $header = "\x50\x4b\x03\x04"; // local file header signature
963 $header .= pack('v', 20); // version needed to extract - 2.0
964 $header .= pack('v', 0); // general purpose flag - no flags set
965 $header .= pack('v', $comp); // compression method - deflate|none
966 $header .= pack(
973 $header .= pack('V', $crc); // crc-32
974 $header .= pack('V', $clen); // compressed size
975 $header .= pack('V', $len); // uncompressed size
976 $header .= pack('v', strlen($name)); // file name length
977 $header .= pack('v', strlen($extra)); // extra field length
978 $header .= $name; // file name
979 $header .= $extra; // extra (utf-8 filename)
980 return $header;
984 * Returns only a part of the local file header containing the CRC, size and compressed size.
985 * Used to update these fields for an already written header.
993 $header = pack('V', $crc); // crc-32
994 $header .= pack('V', $clen); // compressed size
995 $header .= pack('V', $len); // uncompressed size
996 return $header;
1000 * Returns an allowed filename and an extra field header