src/Support/Archive.php
/**
	 * Adds a file to the archive at the specified path.
	 *
	 * @param string $data
	 * @param string $name
	 */
Adds a file to the archive at the specified path.
@param string $data
@param string $name
Adds a file to the archive at the specified path . @param string $data @param string $name
public function createFile($data, $name) {
		$name = str_replace('\\', '/', $name);
		$fr  = "\x50\x4b\x03\x04";
		$fr .= "\x14\x00";
		$fr .= "\x00\x00";
		$fr .= "\x08\x00";
		$fr .= "\x00\x00\x00\x00";
		$unc_len = strlen($data);
		$crc = crc32($data);
		$zdata = gzcompress($data);
		$zdata = substr($zdata, 2, -4);
		$c_len = strlen($zdata);
		$fr .= pack('V', $crc);
		$fr .= pack('V', $c_len);
		$fr .= pack('V', $unc_len);
		$fr .= pack('v', strlen($name));
		$fr .= pack('v', 0);
		$fr .= $name;
		$fr .= $zdata;
		$fr .= pack('V', $crc);
		$fr .= pack('V', $c_len);
		$fr .= pack('V', $unc_len);
		$this->datasec[] = $fr;
		$new_offset = strlen(implode("", $this->datasec));
		$cdrec = "\x50\x4b\x01\x02";
		$cdrec .="\x00\x00";
		$cdrec .="\x14\x00";
		$cdrec .="\x00\x00";
		$cdrec .="\x08\x00";
		$cdrec .="\x00\x00\x00\x00";
		$cdrec .= pack('V', $crc);
		$cdrec .= pack('V', $c_len);
		$cdrec .= pack('V', $unc_len);
		$cdrec .= pack('v', strlen($name));
		$cdrec .= pack('v', 0);
		$cdrec .= pack('v', 0);
		$cdrec .= pack('v', 0);
		$cdrec .= pack('v', 0);
		$cdrec .= pack('V', 32);
		$cdrec .= pack('V', $this->oldOffset);
		$this->oldOffset = $new_offset;
		$this->ctrlDir[] = $cdrec . $name;
	}
public function createFile ( $ data , $ name ) { $ name = str_replace ( '\\' , '/' , $ name ) ; $ fr = " \x50 \x4b \x03 \x04 " ; $ fr .= " \x14 \x00 " ; $ fr .= " \x00 \x00 " ; $ fr .= " \x08 \x00 " ; $ fr .= " \x00 \x00 \x00 \x00 " ; $ unc_len = strlen ( $ data ) ; $ crc = crc32 ( $ data ) ; $ zdata = gzcompress ( $ data ) ; $ zdata = substr ( $ zdata , 2 , - 4 ) ; $ c_len = strlen ( $ zdata ) ; $ fr .= pack ( 'V' , $ crc ) ; $ fr .= pack ( 'V' , $ c_len ) ; $ fr .= pack ( 'V' , $ unc_len ) ; $ fr .= pack ( 'v' , strlen ( $ name ) ) ; $ fr .= pack ( 'v' , 0 ) ; $ fr .= $ name ; $ fr .= $ zdata ; $ fr .= pack ( 'V' , $ crc ) ; $ fr .= pack ( 'V' , $ c_len ) ; $ fr .= pack ( 'V' , $ unc_len ) ; $ this -> datasec [ ] = $ fr ; $ new_offset = strlen ( implode ( " " , $ this -> datasec ) ) ; $ cdrec = " \x50 \x4b \x01 \x02 " ; $ cdrec .= " \x00 \x00 " ; $ cdrec .= " \x14 \x00 " ; $ cdrec .= " \x00 \x00 " ; $ cdrec .= " \x08 \x00 " ; $ cdrec .= " \x00 \x00 \x00 \x00 " ; $ cdrec .= pack ( 'V' , $ crc ) ; $ cdrec .= pack ( 'V' , $ c_len ) ; $ cdrec .= pack ( 'V' , $ unc_len ) ; $ cdrec .= pack ( 'v' , strlen ( $ name ) ) ; $ cdrec .= pack ( 'v' , 0 ) ; $ cdrec .= pack ( 'v' , 0 ) ; $ cdrec .= pack ( 'v' , 0 ) ; $ cdrec .= pack ( 'v' , 0 ) ; $ cdrec .= pack ( 'V' , 32 ) ; $ cdrec .= pack ( 'V' , $ this -> oldOffset ) ; $ this -> oldOffset = $ new_offset ; $ this -> ctrlDir [ ] = $ cdrec . $ name ; }
Adds a file to the archive at the specified path.
Adds a file to the archive at the specified path .
// Local file header // Local file descriptor // Data descriptor // Add to central directory record // Relative offset of local file header