PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » File Formats » Archive_Tar » Bug #9921

compression with bzip2 fails

Details

Submitted2007-01-22 23:31 UTC
Frommartin at proctophantasmist dot cjb dot net
Assignedcellog
StatusClosed
PackageArchive_Tar
PHP Version5.2.0
OSWindows
Roadmaps(Not assigned)

Comments

[2007-01-22 23:31 UTC] martin at proctophantasmist dot cjb dot net

Description:
------------
there is a problem with the calls to bzopen:

when creating an Archive_File object with bz2 compression and calling createModify for instance, the call will fail with this error:

Warning: bzopen() [function.bzopen]: 'wb' is not a valid mode for bzopen(). Only 'w' and 'r' are supported. in [some path}\Tar.php on line 602
Unable to open in write mode '[some file]'

suggested patch:
Index: Archive_Tar/Archive/Tar.php
===================================================================

@@ -599,7 +599,7 @@
if ($this->_compress_type == 'gz')
$this->_file = @gzopen($this->_tarname, "wb9");
else if ($this->_compress_type == 'bz2')
- $this->_file = @bzopen($this->_tarname, "wb");
+ $this->_file = @bzopen($this->_tarname, "w");
else if ($this->_compress_type == 'none')
$this->_file = @fopen($this->_tarname, "wb");
else

works for me.

[2007-01-22 23:41 UTC] martin at proctophantasmist dot cjb dot net

By the way, I don't know if the bug is dependant on the version of php. And I haven't checked the behaviour of bzopen without the "b" with regards to \n ; but I assume it's faithfull to the binary representation of the file originally encoded, I don't see how the "smart" textual behaviour could be preserved through the compression anyway... Though that might be because it is very late here and I am extremely tired.