blob: ba0609dd26eb087c86bcf2d2ba24ba8963a359af (
plain)
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
83
84
85
86
87
88
|
<?php
/**
* Piwik - Open source web analytics
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik
* @package Piwik
*/
namespace Piwik\Unzip;
use Archive_Tar;
/**
* @see libs/Archive_Tar
*/
require_once PIWIK_INCLUDE_PATH . '/libs/Archive_Tar/Tar.php';
/**
* Unzip implementation for Archive_Tar PEAR lib.
*
* @package Piwik
* @subpackage Unzip
*/
class Tar implements UncompressInterface
{
/**
* Archive_Tar instance.
*
* @var Archive_Tar
*/
private $tarArchive = null;
/**
* Constructor.
*
* @param string $filename Path to tar file.
* @param string|null $compression Either 'gz', 'bz2' or null for no compression.
*/
public function __construct($filename, $compression = null)
{
$this->tarArchive = new Archive_Tar($filename, $compression);
}
/**
* Extracts the contents of the tar file to $pathExtracted.
*
* @param string $pathExtracted Directory to extract into.
* @return bool true if successful, false if otherwise.
*/
public function extract($pathExtracted)
{
return $this->tarArchive->extract($pathExtracted);
}
/**
* Extracts one file held in a tar archive and returns the deflated file
* as a string.
*
* @param string $inArchivePath Path to file in the tar archive.
* @return bool true if successful, false if otherwise.
*/
public function extractInString($inArchivePath)
{
return $this->tarArchive->extractInString($inArchivePath);
}
/**
* Lists the files held in the tar archive.
*
* @return array List of paths describing everything held in the tar archive.
*/
public function listContent()
{
return $this->tarArchive->listContent();
}
/**
* Get error status string for the latest error.
*
* @return string
*/
public function errorInfo()
{
return $this->tarArchive->error_object->getMessage();
}
}
|