archive.php
1.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<?php
/**
* @package Joomla.Platform
* @subpackage Archive
*
* @copyright Copyright (C) 2005 - 2019 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
jimport('joomla.filesystem.file');
jimport('joomla.filesystem.folder');
use Joomla\Archive\Archive;
/**
* An Archive handling class
*
* @since 1.5
* @deprecated 4.0 use the Joomla\Archive\Archive class instead
*/
class JArchive
{
/**
* The array of instantiated archive adapters.
*
* @var JArchiveExtractable[]
* @since 3.0.0
*/
protected static $adapters = array();
/**
* Extract an archive file to a directory.
*
* @param string $archivename The name of the archive file
* @param string $extractdir Directory to unpack into
*
* @return boolean True for success
*
* @since 1.5
* @throws InvalidArgumentException
* @deprecated 4.0 use the Joomla\Archive\Archive class instead
*/
public static function extract($archivename, $extractdir)
{
// The archive instance
$archive = new Archive(array('tmp_path' => JFactory::getConfig()->get('tmp_path')));
// Extract the archive
return $archive->extract($archivename, $extractdir);
}
/**
* Get a file compression adapter.
*
* @param string $type The type of adapter (bzip2|gzip|tar|zip).
*
* @return JArchiveExtractable Adapter for the requested type
*
* @since 1.5
* @throws UnexpectedValueException
* @deprecated 4.0 use the Joomla\Archive\Archive class instead
*/
public static function getAdapter($type)
{
if (!isset(self::$adapters[$type]))
{
// Try to load the adapter object
$class = 'JArchive' . ucfirst($type);
if (!class_exists($class))
{
throw new UnexpectedValueException('Unable to load archive', 500);
}
self::$adapters[$type] = new $class;
}
return self::$adapters[$type];
}
}