extractTo
PHPクラスのメソッドを使用しPharData
て phar ファイルの内容を調べ、いくつかのストレージ結果を実行しています。バイト レベルの調査作業の限界に達したので、ここの誰かがこれを整理するのを手伝ってくれることを期待していました。
詳細は次のとおりですが、一般的に言えば、 でアーカイブ ファイルを抽出するとPharData::extractTo
、取得したファイルは亜種のように見えますbzip
が、bzip2
コマンドはそれらを好みません。これは正常phar
な動作ですか、それとも特定のアーカイブの問題ですか? (または、私が使用している PHP/OS の組み合わせの可能性もあります)。phar アーカイブからプレーン テキスト ファイルを取得する方法はありますか? または、プレーン テキストをデフォルトにする必要がありますか?
具体的には、コマンドを実行すると
$phar = new Phar('n98-magerun.phar');
$phar->extractTo('/tmp/n98-magerun');
私の OS 10.6.8 では、組み込みの PHP 5.3.6 を使用する Intel ベースの Mac で、アーカイブは /tmp/n98-magerun フォルダーに正常に抽出されます。
抽出中のアーカイブは、ここにあります。
BBEdit で抽出したテキスト ファイルを開くと、正しい内容が表示されます。
ただし、quicklook、、、vi
またはなどの他のツールを使用すると、cat
バイナリ データが表示されます。ファイルの内容を調べようとしたときにこれに気付きましたack
が、期待した結果が得られませんでした。grep
ファイルに対してコマンドを使用するとfile
、それがファイルであると報告されbzip
ます。
$ file MIT-LICENSE.txt
MIT-LICENSE.txt: bzip2 compressed data, block size = 400k
16進エディタでファイルを調べると、ファイルがBZ
ヘッダーで始まることが確認されます
ただし、ファイルを解凍しようとすると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.