1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace wapmorgan\UnifiedArchive\Drivers; |
4
|
|
|
|
5
|
|
|
use wapmorgan\UnifiedArchive\Drivers\Basic\BasicDriver; |
6
|
|
|
use wapmorgan\UnifiedArchive\Drivers\Basic\BasicPureDriver; |
7
|
|
|
use wapmorgan\UnifiedArchive\Formats; |
8
|
|
|
|
9
|
|
|
class SplitbrainPhpArchive extends BasicPureDriver |
10
|
|
|
{ |
11
|
|
|
const PACKAGE_NAME = 'splitbrain/php-archive'; |
12
|
|
|
const MAIN_CLASS = '\\splitbrain\\PHPArchive\\Tar'; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* @inheritDoc |
16
|
|
|
*/ |
17
|
|
|
public static function getDescription() |
18
|
|
|
{ |
19
|
|
|
return 'php-library for zip/tar (with gzip/bzip-compression)'; |
20
|
|
|
} |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* @inheritDoc |
24
|
|
|
*/ |
25
|
|
|
public static function getSupportedFormats() |
26
|
|
|
{ |
27
|
|
|
return [ |
28
|
|
|
Formats::ZIP, |
29
|
|
|
Formats::TAR, |
30
|
|
|
Formats::TAR_GZIP, |
31
|
|
|
Formats::TAR_BZIP, |
32
|
|
|
]; |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @inheritDoc |
37
|
|
|
*/ |
38
|
|
|
public static function checkFormatSupport($format) |
39
|
|
|
{ |
40
|
|
|
if (!static::isInstalled()) { |
41
|
|
|
return []; |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
if ( |
45
|
|
|
($format === Formats::TAR_BZIP && !extension_loaded('bzip2')) |
46
|
|
|
|| ($format === Formats::TAR_GZIP && !extension_loaded('zlib')) |
47
|
|
|
) { |
48
|
|
|
return []; |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
switch ($format) { |
52
|
|
|
case Formats::ZIP: |
53
|
|
|
case Formats::TAR: |
54
|
|
|
case Formats::TAR_GZIP; |
55
|
|
|
case Formats::TAR_BZIP; |
56
|
|
|
return [ |
57
|
|
|
BasicDriver::OPEN, |
58
|
|
|
// BasicDriver::EXTRACT_CONTENT, |
59
|
|
|
BasicDriver::APPEND, |
60
|
|
|
BasicDriver::CREATE, |
61
|
|
|
BasicDriver::CREATE_ENCRYPTED, |
62
|
|
|
BasicDriver::CREATE_IN_STRING, |
63
|
|
|
]; |
64
|
|
|
} |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* @inheritDoc |
69
|
|
|
*/ |
70
|
|
|
public function getArchiveInformation() |
71
|
|
|
{ |
72
|
|
|
// TODO: Implement getArchiveInformation() method. |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* @inheritDoc |
77
|
|
|
*/ |
78
|
|
|
public function getFileNames() |
79
|
|
|
{ |
80
|
|
|
// TODO: Implement getFileNames() method. |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* @inheritDoc |
85
|
|
|
*/ |
86
|
|
|
public function isFileExists($fileName) |
87
|
|
|
{ |
88
|
|
|
// TODO: Implement isFileExists() method. |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* @inheritDoc |
93
|
|
|
*/ |
94
|
|
|
public function getFileData($fileName) |
95
|
|
|
{ |
96
|
|
|
// TODO: Implement getFileData() method. |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* @inheritDoc |
101
|
|
|
*/ |
102
|
|
|
public function getFileContent($fileName) |
103
|
|
|
{ |
104
|
|
|
// TODO: Implement getFileContent() method. |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
/** |
108
|
|
|
* @inheritDoc |
109
|
|
|
*/ |
110
|
|
|
public function getFileStream($fileName) |
111
|
|
|
{ |
112
|
|
|
// TODO: Implement getFileStream() method. |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
/** |
116
|
|
|
* @inheritDoc |
117
|
|
|
*/ |
118
|
|
|
public function extractFiles($outputFolder, array $files) |
119
|
|
|
{ |
120
|
|
|
// TODO: Implement extractFiles() method. |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
/** |
124
|
|
|
* @inheritDoc |
125
|
|
|
*/ |
126
|
|
|
public function extractArchive($outputFolder) |
127
|
|
|
{ |
128
|
|
|
// TODO: Implement extractArchive() method. |
129
|
|
|
} |
130
|
|
|
} |
131
|
|
|
|