function Archive_Tar::_writeHeaderBlock
2 calls to Archive_Tar::_writeHeaderBlock()
- Archive_Tar::_addString in drupal-7.x/modules/system/system.tar.inc
- Archive_Tar::_addString in drupal-7.x/modules/system/system.tar.inc
Archivo
- drupal-7.x/modules/system/system.tar.inc, line 1139
Class
- Archive_Tar
- Creates a (compressed) Tar archive
*
Código
function _writeHeaderBlock($p_filename, $p_size, $p_mtime = 0, $p_perms = 0, $p_type = '', $p_uid = 0, $p_gid = 0) {
$p_filename = $this->_pathReduction($p_filename);
if (strlen($p_filename) > 99) {
if (!$this->_writeLongHeader($p_filename)) {
return false;
}
}
if ($p_type == "5") {
$v_size = sprintf("%11s ", DecOct(0));
}
else {
$v_size = sprintf("%11s ", DecOct($p_size));
}
$v_uid = sprintf("%6s ", DecOct($p_uid));
$v_gid = sprintf("%6s ", DecOct($p_gid));
$v_perms = sprintf("%6s ", DecOct($p_perms));
$v_mtime = sprintf("%11s", DecOct($p_mtime));
$v_linkname = '';
$v_magic = '';
$v_version = '';
$v_uname = '';
$v_gname = '';
$v_devmajor = '';
$v_devminor = '';
$v_prefix = '';
$v_binary_data_first = pack("a100a8a8a8a12A12", $p_filename, $v_perms, $v_uid, $v_gid, $v_size, $v_mtime);
$v_binary_data_last = pack("a1a100a6a2a32a32a8a8a155a12", $p_type, $v_linkname, $v_magic, $v_version, $v_uname, $v_gname, $v_devmajor, $v_devminor, $v_prefix, '');
$v_checksum = 0;
for ($i = 0; $i < 148; $i++) {
$v_checksum += ord(substr($v_binary_data_first, $i, 1));
};
for ($i = 148; $i < 156; $i++) {
$v_checksum += ord(' ');
};
for ($i = 156, $j = 0; $i < 512; $i++, $j++) {
$v_checksum += ord(substr($v_binary_data_last, $j, 1));
};
$this->_writeBlock($v_binary_data_first, 148);
$v_checksum = sprintf("%6s ", DecOct($v_checksum));
$v_binary_data = pack("a8", $v_checksum);
$this->_writeBlock($v_binary_data, 8);
$this->_writeBlock($v_binary_data_last, 356);
return true;
}