function Archive_Tar($p_tarname, $p_compress = null)
    {
        $this->PEAR();
        $this->_compress = false;
        $this->_compress_type = 'none';
        if (($p_compress === null) || ($p_compress == '')) {
            if (@file_exists($p_tarname)) {
                if ($fp = @fopen($p_tarname, "rb")) {
                    // look for gzip magic cookie
                    $data = fread($fp, 2);
                    fclose($fp);
                    if ($data == "\37\213") {
                        $this->_compress = true;
                        $this->_compress_type = 'gz';
                        // No sure it's enought for a magic code ....
                    } elseif ($data == "BZ") {
                        $this->_compress = true;
                        $this->_compress_type = 'bz2';
                    }
                }
            } else {
                // probably a remote file or some file accessible
                // through a stream interface
                if (substr($p_tarname, -2) == 'gz') {
                    $this->_compress = true;
                    $this->_compress_type = 'gz';
                } elseif ((substr($p_tarname, -3) == 'bz2') ||
                          (substr($p_tarname, -2) == 'bz')) {
                    $this->_compress = true;
                    $this->_compress_type = 'bz2';
                }
            }
        } else {
            if (($p_compress === true) || ($p_compress == 'gz')) {
                $this->_compress = true;
                $this->_compress_type = 'gz';
            } else if ($p_compress == 'bz2') {
                $this->_compress = true;
                $this->_compress_type = 'bz2';
            } else {
                $this->_error("Unsupported compression type '$p_compress'\n".
                    "Supported types are 'gz' and 'bz2'.\n");
                return false;
            }
        }
        $this->_tarname = $p_tarname;
        if ($this->_compress) { // assert zlib or bz2 extension support
            if ($this->_compress_type == 'gz')
                $extname = 'zlib';
            else if ($this->_compress_type == 'bz2')
                $extname = 'bz2';

            if (!extension_loaded($extname)) {
                PEAR::loadExtension($extname);
            }
            if (!extension_loaded($extname)) {
                $this->_error("The extension '$extname' couldn't be found.\n".
                    "Please make sure your version of PHP was built ".
                    "with '$extname' support.\n");
                return false;
            }
        }
    }
function Archive_Tar($p_tarname, $p_compress = null)
    {
        $this->PEAR();
        $this->_compress = false;
        $this->_compress_type = 'none';
        if (($p_compress === null) || ($p_compress == '')) {
            if (@file_exists($p_tarname)) {
                if ($fp = @fopen($p_tarname, "rb")) {
                    // look for gzip magic cookie
                    $data = fread($fp, 2);
                    fclose($fp);
                    if ($data == "\37\213") {
                        $this->_compress = true;
                        $this->_compress_type = 'gz';
                        // No sure it's enought for a magic code ....
                    } elseif ($data == "BZ") {
                        $this->_compress = true;
                        $this->_compress_type = 'bz2';
                    }
                }
            } else {
                // probably a remote file or some file accessible
                // through a stream interface
                if (substr($p_tarname, -2) == 'gz') {
                    $this->_compress = true;
                    $this->_compress_type = 'gz';
                } elseif ((substr($p_tarname, -3) == 'bz2') ||
                          (substr($p_tarname, -2) == 'bz')) {
                    $this->_compress = true;
                    $this->_compress_type = 'bz2';
                }
            }
        } else {
            if (($p_compress === true) || ($p_compress == 'gz')) {
                $this->_compress = true;
                $this->_compress_type = 'gz';
            } else if ($p_compress == 'bz2') {
                $this->_compress = true;
                $this->_compress_type = 'bz2';
            } else {
                $this->_error("Unsupported compression type '$p_compress'\n".
                    "Supported types are 'gz' and 'bz2'.\n");
                return false;
            }
        }
        $this->_tarname = $p_tarname;
        if ($this->_compress) { // assert zlib or bz2 extension support
            if ($this->_compress_type == 'gz')
                $extname = 'zlib';
            else if ($this->_compress_type == 'bz2')
                $extname = 'bz2';

            if (!extension_loaded($extname)) {
                PEAR::loadExtension($extname);
            }
            if (!extension_loaded($extname)) {
                $this->_error("The extension '$extname' couldn't be found.\n".
                    "Please make sure your version of PHP was built ".
                    "with '$extname' support.\n");
                return false;
            }
        }
    }
function Archive_Tar ( $ p_tarname , $ p_compress = null ) { $ this -> PEAR ( ) ; $ this -> _compress = false ; $ this -> _compress_type = 'none' ; if ( ( $ p_compress === null ) || ( $ p_compress == '' ) ) { if ( @ file_exists ( $ p_tarname ) ) { if ( $ fp = @ fopen ( $ p_tarname , "rb" ) ) { // look for gzip magic cookie $ data = fread ( $ fp , 2 ) ; fclose ( $ fp ) ; if ( $ data == "\37\213" ) { $ this -> _compress = true ; $ this -> _compress_type = 'gz' ; // No sure it's enought for a magic code .... } elseif ( $ data == "BZ" ) { $ this -> _compress = true ; $ this -> _compress_type = 'bz2' ; } } } else { // probably a remote file or some file accessible // through a stream interface if ( substr ( $ p_tarname , - 2 ) == 'gz' ) { $ this -> _compress = true ; $ this -> _compress_type = 'gz' ; } elseif ( ( substr ( $ p_tarname , - 3 ) == 'bz2' ) || ( substr ( $ p_tarname , - 2 ) == 'bz' ) ) { $ this -> _compress = true ; $ this -> _compress_type = 'bz2' ; } } } else { if ( ( $ p_compress === true ) || ( $ p_compress == 'gz' ) ) { $ this -> _compress = true ; $ this -> _compress_type = 'gz' ; } else if ( $ p_compress == 'bz2' ) { $ this -> _compress = true ; $ this -> _compress_type = 'bz2' ; } else { $ this -> _error ( "Unsupported compression type '$p_compress'\n" . "Supported types are 'gz' and 'bz2'.\n" ) ; return false ; } } $ this -> _tarname = $ p_tarname ; if ( $ this -> _compress ) { // assert zlib or bz2 extension support if ( $ this -> _compress_type == 'gz' ) $ extname = 'zlib' ; else if ( $ this -> _compress_type == 'bz2' ) $ extname = 'bz2' ; if ( ! extension_loaded ( $ extname ) ) { PEAR :: loadExtension ( $ extname ) ; } if ( ! extension_loaded ( $ extname ) ) { $ this -> _error ( "The extension '$extname' couldn't be found.\n" . "Please make sure your version of PHP was built " . "with '$extname' support.\n" ) ; return false ; } } }
Archive_Tar Class constructor. This flavour of the constructor only
declare a new Archive_Tar object, identifying it by the name of the
tar file.
If the compress argument is set the tar will be read or created as a
gzip or bz2 compressed TAR file.

@param string $p_tarname  The name of the tar archive to create
@param string $p_compress can be null, 'gz' or 'bz2'. This
parameter indicates if gzip or bz2 compression
is required.  For compatibility reason the
boolean value 'true' means 'gz'.

@access public
Archive_Tar Class constructor . This flavour of the constructor only declare a new Archive_Tar object identifying it by the name of the tar file . If the compress argument is set the tar will be read or created as a gzip or bz2 compressed TAR file .