What file format does PharData :: extractTo contain How to extract files?

I am using a extractToPHP class method PharDatato examine the contents of a phar file and work with some degradation results. I went to the limits of the detective work of my byte level and was hoping that someone here could help me figure this out.

Details follow, but generally speaking: when I extract my archive files using PharData::extractTo, the files I receive are bzipvarient, but bzip2they don’t like the command . Is this normal behavior phar, or is it a problem with a specific archive? (or maybe the combination of PHP / OS that I am using). Is there a way to get text files from a phar archive - or should there be plain text by default, and I look at the strange behavior of the system?

In particular, when I run the command

$phar = new Phar('n98-magerun.phar');
$phar->extractTo('/tmp/n98-magerun');

In my OS 10.6.8, based on Intel Mac using the built-in PHP 5.3.6, the archive is successfully extracted to the / tmp / n 98-magerun folder.

enter image description here

The archive that I am extracting can be found here .

If I open any of the text files extracted in BBEdit, I see the correct content.

enter image description here

, , quicklook, vi cat, . ack/grep , .

enter image description here

file , , bzip.

$ file MIT-LICENSE.txt 
MIT-LICENSE.txt: bzip2 compressed data, block size = 400k

, BZ

enter image description here

bzip2

$ bzip2 -d MIT-LICENSE.txt 
bzip2: Can't guess original name for MIT-LICENSE.txt -- using MIT-LICENSE.txt.out

bzip2: Compressed file ends unexpectedly;
    perhaps it is corrupted?  *Possible* reason follows.
bzip2: No such file or directory
    Input file = MIT-LICENSE.txt, output file = MIT-LICENSE.txt.out

It is possible that the compressed file(s) have become corrupted.
You can use the -tvv option to test integrity of such files.

You can use the `bzip2recover' program to attempt to recover
data from undamaged sections of corrupted files.

bzip2: Deleting output file MIT-LICENSE.txt.out, if it exists.

bzcat ,

bzcat: Compressed file ends unexpectedly;
    perhaps it is corrupted?  *Possible* reason follows.
bzcat: Undefined error: 0
    Input file = MIT-LICENSE.txt, output file = (stdout)

It is possible that the compressed file(s) have become corrupted.
You can use the -tvv option to test integrity of such files.

You can use the `bzip2recover' program to attempt to recover
data from undamaged sections of corrupted files.
+5
2

bzip2, --stdout ( -c) (. ).

, --stdout, - .bz2, bunzip2 .

$ bunzip2 --stdout MIT-LICENSE.txt 2>/dev/null
Copyright (c) 2012 netz98 new media GmbH

http://www.netz98.de

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE

, bunzip2 :

bzip2: Compressed file ends unexpectedly;
        perhaps it is corrupted?  *Possible* reason follows.
bzip2: Success
        Input file = MIT-LICENSE.txt, output file = (stdout)

It is possible that the compressed file(s) have become corrupted.
You can use the -tvv option to test integrity of such files.

You can use the `bzip2recover' program to attempt to recover
data from undamaged sections of corrupted files.

file, bzip2 400k:

$ file MIT-LICENSE.txt 
MIT-LICENSE.txt: bzip2 compressed data, block size = 400k

-4 bunzip2, :

$ bunzip2 -d -4 -vvvvv -c  MIT-LICENSE.txt >/dev/null 
  MIT-LICENSE.txt: 
    [1: huff+mtf rt+rld {0x2010d4b9, 0x2010d4b9}]
    combined CRCs: stored = 0x2010d4b9, computed = 0x2010d4b9
    [1: huff+mtf 
bunzip2: Compressed file ends unexpectedly;
        perhaps it is corrupted?  *Possible* reason follows.
bunzip2: Success
        Input file = MIT-LICENSE.txt, output file = (stdout)

It is possible that the compressed file(s) have become corrupted.
You can use the -tvv option to test integrity of such files.

You can use the `bzip2recover' program to attempt to recover
data from undamaged sections of corrupted files.

, , bzip2.

+1

extractTo, , ! : none, gzip, bzip2

, , , -, : phar phar !

:

<?php
$phar = new Phar('Someclass.phar');
$phar2 = $phar->convertToExecutable (Phar::TAR,Phar::NONE); //convert to an uncompressed tar archive
$phar2->extractTo('/some/path/'); // extract all files

!

0

All Articles