function features_tar_create in Features 7
Same name and namespace in other branches
- 6 features.export.inc \features_tar_create()
- 7.2 features.export.inc \features_tar_create()
Tar creation function. Written by dmitrig01.
Parameters
$name: Filename of the file to be tarred.
$contents: String contents of the file.
Return value
A string of the tar file contents.
1 call to features_tar_create()
- features_export_build_form_submit in ./
features.admin.inc - Form submission handler for features_export_form().
File
- ./
features.export.inc, line 429
Code
function features_tar_create($name, $contents) {
$tar = '';
$binary_data_first = pack("a100a8a8a8a12A12", $name, '100644 ', ' 765 ', ' 765 ', sprintf("%11s ", decoct(strlen($contents))), sprintf("%11s", decoct(REQUEST_TIME)));
$binary_data_last = pack("a1a100a6a2a32a32a8a8a155a12", '', '', '', '', '', '', '', '', '', '');
$checksum = 0;
for ($i = 0; $i < 148; $i++) {
$checksum += ord(substr($binary_data_first, $i, 1));
}
for ($i = 148; $i < 156; $i++) {
$checksum += ord(' ');
}
for ($i = 156, $j = 0; $i < 512; $i++, $j++) {
$checksum += ord(substr($binary_data_last, $j, 1));
}
$tar .= $binary_data_first;
$tar .= pack("a8", sprintf("%6s ", decoct($checksum)));
$tar .= $binary_data_last;
$buffer = str_split($contents, 512);
foreach ($buffer as $item) {
$tar .= pack("a512", $item);
}
return $tar;
}