--- Tar.php 1970-01-01 01:14:39.000000000 -0800 +++ system.tar.inc 2009-06-09 10:33:49.000000000 -0700 @@ -40,9 +40,6 @@ * @link http://pear.php.net/package/Archive_Tar */ -require_once 'PEAR.php'; - - define ('ARCHIVE_TAR_ATT_SEPARATOR', 90001); define ('ARCHIVE_TAR_END_BLOCK', pack("a512", '')); @@ -54,7 +51,7 @@ define ('ARCHIVE_TAR_END_BLOCK', pack("a * @license http://www.opensource.org/licenses/bsd-license.php New BSD License * @package Archive_Tar */ -class Archive_Tar extends PEAR +class Archive_Tar { /** * @var string Name of the Tar @@ -101,9 +98,8 @@ class Archive_Tar extends PEAR * boolean value 'true' means 'gz'. * @access public */ - function Archive_Tar($p_tarname, $p_compress = null) + function __construct($p_tarname, $p_compress = null) { - $this->PEAR(); $this->_compress = false; $this->_compress_type = 'none'; if (($p_compress === null) || ($p_compress == '')) { @@ -154,7 +150,7 @@ class Archive_Tar extends PEAR $extname = 'bz2'; if (!extension_loaded($extname)) { - PEAR::loadExtension($extname); + $this->loadExtension($extname); } if (!extension_loaded($extname)) { die("The extension '$extname' couldn't be found.\n". @@ -166,14 +162,47 @@ class Archive_Tar extends PEAR } // }}} + /** + * OS independant PHP extension load. Remember to take care + * on the correct extension name for case sensitive OSes. + * + * @param string $ext The extension name + * @return bool Success or not on the dl() call + */ + function loadExtension($ext) + { + if (!extension_loaded($ext)) { + // if either returns true dl() will produce a FATAL error, stop that + if ((ini_get('enable_dl') != 1) || (ini_get('safe_mode') == 1)) { + return false; + } + + if (OS_WINDOWS) { + $suffix = '.dll'; + } elseif (PHP_OS == 'HP-UX') { + $suffix = '.sl'; + } elseif (PHP_OS == 'AIX') { + $suffix = '.a'; + } elseif (PHP_OS == 'OSX') { + $suffix = '.bundle'; + } else { + $suffix = '.so'; + } + + return @dl('php_'.$ext.$suffix) || @dl($ext.$suffix); + } + + return true; + } + + // {{{ destructor - function _Archive_Tar() + function __destruct() { $this->_close(); // ----- Look for a local copy to delete if ($this->_temp_tarname != '') @unlink($this->_temp_tarname); - $this->_PEAR(); } // }}} @@ -593,7 +622,7 @@ class Archive_Tar extends PEAR function _error($p_message) { // ----- To be completed - $this->raiseError($p_message); + throw new Exception($p_message); } // }}} @@ -601,7 +630,7 @@ class Archive_Tar extends PEAR function _warning($p_message) { // ----- To be completed - $this->raiseError($p_message); + throw new Exception($p_message); } // }}}