function _addFile($p_filename, &$p_header, $p_add_dir, $p_remove_dir) {
if (!$this->_file) {
$this
->_error('Invalid file descriptor');
return false;
}
if ($p_filename == '') {
$this
->_error('Invalid file name');
return false;
}
// ----- Calculate the stored filename
$p_filename = $this
->_translateWinPath($p_filename, false);
$v_stored_filename = $p_filename;
if (strcmp($p_filename, $p_remove_dir) == 0) {
return true;
}
if ($p_remove_dir != '') {
if (substr($p_remove_dir, -1) != '/') {
$p_remove_dir .= '/';
}
if (substr($p_filename, 0, strlen($p_remove_dir)) == $p_remove_dir) {
$v_stored_filename = substr($p_filename, strlen($p_remove_dir));
}
}
$v_stored_filename = $this
->_translateWinPath($v_stored_filename);
if ($p_add_dir != '') {
if (substr($p_add_dir, -1) == '/') {
$v_stored_filename = $p_add_dir . $v_stored_filename;
}
else {
$v_stored_filename = $p_add_dir . '/' . $v_stored_filename;
}
}
$v_stored_filename = $this
->_pathReduction($v_stored_filename);
if ($this
->_isArchive($p_filename)) {
if (($v_file = @fopen($p_filename, "rb")) == 0) {
$this
->_warning("Unable to open file '" . $p_filename . "' in binary read mode");
return true;
}
if (!$this
->_writeHeader($p_filename, $v_stored_filename)) {
return false;
}
while (($v_buffer = fread($v_file, 512)) != '') {
$v_binary_data = pack("a512", "{$v_buffer}");
$this
->_writeBlock($v_binary_data);
}
fclose($v_file);
}
else {
// ----- Only header for dir
if (!$this
->_writeHeader($p_filename, $v_stored_filename)) {
return false;
}
}
return true;
}