decompressing phar file not getting sane results

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



running in CLI mode. readonly for Phars is set to 'off'
If I do $p->extractTo() BEFORE compressing it, I ca the right results when I do
cat *.txt in directory extracted to. But if I compress it and then decompress it, I get garbage.

-------------------------------------------------------------------------
CODE
----------------------------------------------------------------------------

<?php
$p = new Phar('/home/gearond/my.phar', FilesystemIterator::SKIP_DOTS | FilesystemIterator::UNIX_PATHS, 'my.phar');
$p['myfile.txt'] = 'four score and seven years ago our fathers.';
$p['myfile2.txt'] = 'four score and severn years ago our mothers.';
foreach ($p as $file) {
    var_dump($file->getFileName());
    var_dump($file->isCompressed());
    var_dump($file->isCompressed(Phar::BZ2));
    var_dump($file->isCompressed(Phar::GZ));
}
var_dump($p->getSupportedCompression() );
var_dump( $p->compressFiles(Phar::GZ) );
foreach ($p as $file) {
    var_dump($file->getFileName());
    var_dump($file->isCompressed());
    var_dump($file->isCompressed(Phar::BZ2));
    var_dump($file->isCompressed(Phar::GZ));
}
var_dump( $p->decompressFiles() );
foreach ($p as $file) {
    var_dump($file->getFileName());
    var_dump($file->isCompressed());
    var_dump($file->isCompressed(Phar::BZ2));
    var_dump($file->isCompressed(Phar::GZ));
}
var_dump( $p->extractTo("./", null, true) );
?>


---------------------------------------------------------------------------
RESULTS
----------------------------------------------------------------------------

string(10) "myfile.txt"
bool(false)
bool(false)
bool(false)
string(11) "myfile2.txt"
bool(false)
bool(false)
bool(false)
array(2) {
  [0]=>
  string(2) "GZ"
  [1]=>
  string(5) "BZIP2"
}
NULL
string(10) "myfile.txt"
bool(true)
bool(false)
bool(true)
string(11) "myfile2.txt"
bool(true)
bool(false)
bool(true)
bool(true)
string(10) "myfile.txt"
bool(false)
bool(false)
bool(false)
string(11) "myfile2.txt"
bool(false)
bool(false)
bool(false)
bool(true)

---------------------------------------------------------------------------
FILE CONTENT
----------------------------------------------------------------------------
The results of cat *.txt in the director extracted to are:

cat *.txt
K�/-R(N�/JUH�KQ(N-K-�S�LM,*VHL�WI��d��K�/-R(N�/JUH�KQ(N-K�S�LM,*VHL�Wɦ%�d��


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux