diff options
author | Andreas Gohr <andi@splitbrain.org> | 2015-05-15 15:17:39 +0200 |
---|---|---|
committer | Andreas Gohr <andi@splitbrain.org> | 2015-05-15 15:42:12 +0200 |
commit | 605f8e8d0e501057749c50581087ce05089c1af3 (patch) | |
tree | 9c30eb312b348a091a41c6b3ff800ce0c5f8b635 /lib | |
parent | 05790a01307aa347e77502603791afd84d62aa8b (diff) | |
download | rpg-605f8e8d0e501057749c50581087ce05089c1af3.tar.gz rpg-605f8e8d0e501057749c50581087ce05089c1af3.tar.bz2 |
added composer setup and the first composer package php-archive
Diffstat (limited to 'lib')
-rw-r--r-- | lib/plugins/extension/helper/extension.php | 27 |
1 files changed, 9 insertions, 18 deletions
diff --git a/lib/plugins/extension/helper/extension.php b/lib/plugins/extension/helper/extension.php index 6c0946b09..d089245b5 100644 --- a/lib/plugins/extension/helper/extension.php +++ b/lib/plugins/extension/helper/extension.php @@ -1035,33 +1035,24 @@ class helper_plugin_extension_extension extends DokuWiki_Plugin { $ext = $this->guess_archive($file); if(in_array($ext, array('tar', 'bz', 'gz'))) { - switch($ext) { - case 'bz': - $compress_type = Tar::COMPRESS_BZIP; - break; - case 'gz': - $compress_type = Tar::COMPRESS_GZIP; - break; - default: - $compress_type = Tar::COMPRESS_NONE; - } - $tar = new Tar(); try { - $tar->open($file, $compress_type); + $tar = new \splitbrain\PHPArchive\Tar(); + $tar->open($file); $tar->extract($target); - } catch (Exception $e) { + } catch (\splitbrain\PHPArchive\ArchiveIOException $e) { throw new Exception($this->getLang('error_decompress').' '.$e->getMessage()); } return true; } elseif($ext == 'zip') { - $zip = new ZipLib(); - $ok = $zip->Extract($file, $target); - - if($ok == -1){ - throw new Exception($this->getLang('error_decompress').' Error extracting the zip archive'); + try { + $zip = new \splitbrain\PHPArchive\Zip(); + $zip->open($file); + $zip->extract($target); + } catch (\splitbrain\PHPArchive\ArchiveIOException $e) { + throw new Exception($this->getLang('error_decompress').' '.$e->getMessage()); } return true; |