ce4c2b525078527318136187d25f95b83ec1bfcc
3 namespace pharext\Task
;
9 class PaxFixup
implements Task
13 public function __construct($source) {
14 $this->source
= $source;
17 private function openArchive($source) {
18 $hdr = file_get_contents($source, false, null, 0, 3);
19 if ($hdr === "\x1f\x8b\x08") {
20 $fd = fopen("compress.zlib://$source", "r");
21 } elseif ($hdr === "BZh") {
22 $fd = fopen("compress.bzip2://$source", "r");
24 $fd = fopen($source, "r");
26 if (!is_resource($fd)) {
32 public function run($verbose = false) {
33 if ($verbose !== false) {
34 printf("Fixing up a tarball with global pax header ...\n");
36 $temp = new Tempfile("paxfix");
37 stream_copy_to_stream($this->openArchive($this->source
),
38 $temp->getStream(), -1, 1024);
40 return (new Extract((string) $temp))->run($verbose);