protected function addFileHeader($name, &$opt, $meth, $crc, $zlen, $len, $genb = 0x0)
{
// strip leading slashes from file name
// (fixes bug in windows archive viewer)
$name = preg_replace('/^\\/+/', '', $name);
// calculate name length
$nlen = strlen($name);
// create dos timestamp
$opt['time'] = isset($opt['time']) && !empty($opt['time']) ? $opt['time'] : time();
$dts = $this->dostime($opt['time']);
if (mb_check_encoding($name, "UTF-8") && !mb_check_encoding($name, "ASCII")) {
// Sets Bit 11: Language encoding flag (EFS). If this bit is set,
// the filename and comment fields for this file
// MUST be encoded using UTF-8. (see APPENDIX D)
$genb |= 0x800;
}
// build file header
$fields = array(array('V', 0x4034b50), array('v', 0xa), array('v', $genb), array('v', $meth), array('V', $dts), array('V', $crc), array('V', $zlen), array('V', $len), array('v', $nlen), array('v', 0));
// pack fields and calculate "total" length
$ret = $this->packFields($fields);
$header = $ret . $name;
$num_bytes_written = strlen($header);
// print header and filename
$this->send($header);
return $num_bytes_written;
}