diff options
author | Andreas Gohr <andi@splitbrain.org> | 2012-11-06 20:57:25 +0100 |
---|---|---|
committer | Andreas Gohr <andi@splitbrain.org> | 2012-11-06 20:57:25 +0100 |
commit | 35349ab097171f0f9cb6114cffd780abb69c56a6 (patch) | |
tree | e0b9b1d4f009b6fe294cca10ca7c6844ffae1aa8 | |
parent | 2949ece61602372cf55fba6be4522fa8899fb70d (diff) | |
download | rpg-35349ab097171f0f9cb6114cffd780abb69c56a6.tar.gz rpg-35349ab097171f0f9cb6114cffd780abb69c56a6.tar.bz2 |
added simple compatibility wrapper for old TarLib
-rw-r--r-- | inc/TarLib.class.php | 87 | ||||
-rw-r--r-- | inc/load.php | 1 |
2 files changed, 88 insertions, 0 deletions
diff --git a/inc/TarLib.class.php b/inc/TarLib.class.php new file mode 100644 index 000000000..ae08039ec --- /dev/null +++ b/inc/TarLib.class.php @@ -0,0 +1,87 @@ +<?php + +/** + * This is a compatibility wrapper around the new Tar class + * + * Use of this library is strongly discouraged. Only basic extraction is wrapped, + * everything else will fail. + * + * @deprecated 2012-11-06 + */ +class TarLib { + + const COMPRESS_GZIP = 1; + const COMPRESS_BZIP = 2; + const COMPRESS_AUTO = 3; + const COMPRESS_NONE = 0; + const TARLIB_VERSION = '1.2'; + const FULL_ARCHIVE = -1; + const ARCHIVE_DYNAMIC = 0; + const ARCHIVE_RENAMECOMP = 5; + const COMPRESS_DETECT = -1; + + private $file = ''; + private $tar; + + public $_result = true; + + function __construct($file, $comptype = TarLib::COMPRESS_AUTO, $complevel = 9) { + if(!$file) $this->error('__construct', '$file'); + + $this->file = $file; + switch($comptype) { + case TarLib::COMPRESS_AUTO: + case TarLib::COMPRESS_DETECT: + $comptype = Tar::COMPRESS_AUTO; + break; + case TarLib::COMPRESS_GZIP: + $comptype = Tar::COMPRESS_GZIP; + break; + case TarLib::COMPRESS_BZIP: + $comptype = Tar::COMPRESS_BZIP; + break; + default: + $comptype = Tar::COMPRESS_NONE; + } + + $this->complevel = $complevel; + + try { + $this->tar = new Tar(); + $this->tar->open($file, $comptype); + } catch(Exception $e) { + $this->_result = false; + } + } + + function Extract($p_what = TarLib::FULL_ARCHIVE, $p_to = '.', $p_remdir = '', $p_mode = 0755) { + if($p_what != TarLib::FULL_ARCHIVE) { + $this->error('Extract', 'Ep_what'); + return 0; + } + + try { + $this->tar->extract($p_to, $p_remdir); + } catch(Exception $e) { + return 0; + } + return 1; + } + + function error($func, $param = '') { + $error = 'TarLib is deprecated and should no longer be used.'; + + if($param) { + $error .= "In this compatibility wrapper, the function '$func' does not accept your value for". + "the parameter '$param' anymore."; + } else { + $error .= "The function '$func' no longer exists in this compatibility wrapper."; + } + + msg($error, -1); + } + + function __call($name, $arguments) { + $this->error($name); + } +}
\ No newline at end of file diff --git a/inc/load.php b/inc/load.php index 2ea0d8efd..49c307054 100644 --- a/inc/load.php +++ b/inc/load.php @@ -72,6 +72,7 @@ function load_autoload($name){ 'Doku_Plugin_Controller'=> DOKU_INC.'inc/plugincontroller.class.php', 'GeSHi' => DOKU_INC.'inc/geshi.php', 'Tar' => DOKU_INC.'inc/Tar.class.php', + 'TarLib' => DOKU_INC.'inc/TarLib.class.php', 'ZipLib' => DOKU_INC.'inc/ZipLib.class.php', 'DokuWikiFeedCreator' => DOKU_INC.'inc/feedcreator.class.php', 'Doku_Parser_Mode' => DOKU_INC.'inc/parser/parser.php', |