10 defined(
'JPATH_PLATFORM') or die;
12 jimport('joomla.filesystem.file');
13 jimport('joomla.filesystem.folder');
28 protected static $adapters = array();
41 public static function extract($archivename, $extractdir)
56 $adapter = self::getAdapter(
'zip');
60 $result = $adapter->extract($archivename, $extractdir);
65 $adapter = self::getAdapter(
'tar');
69 $result = $adapter->extract($archivename, $extractdir);
80 $adapter = self::getAdapter(
'gzip');
85 $tmpfname = $config->get(
'tmp_path') .
'/' . uniqid(
'gzip');
86 $gzresult = $adapter->extract($archivename, $tmpfname);
88 if ($gzresult instanceof Exception)
98 $tadapter = self::getAdapter(
'tar');
102 $result = $tadapter->extract($tmpfname, $extractdir);
123 $adapter = self::getAdapter(
'bzip2');
128 $tmpfname = $config->get(
'tmp_path') .
'/' . uniqid(
'bzip2');
129 $bzresult = $adapter->extract($archivename, $tmpfname);
131 if ($bzresult instanceof Exception)
141 $tadapter = self::getAdapter(
'tar');
145 $result = $tadapter->extract($tmpfname, $extractdir);
160 throw new InvalidArgumentException(
'Unknown Archive Type');
163 if (!$result || $result instanceof Exception)
181 public static function getAdapter($type)
183 if (!isset(self::$adapters[$type]))
186 $class =
'JArchive' . ucfirst($type);
188 if (!class_exists($class))
190 throw new UnexpectedValueException(
'Unable to load archive', 500);
193 self::$adapters[$type] =
new $class;
196 return self::$adapters[$type];