|
1
|
|
|
<?php |
|
2
|
|
|
namespace wapmorgan\UnifiedArchive\Formats; |
|
3
|
|
|
|
|
4
|
|
|
use wapmorgan\UnifiedArchive\ArchiveEntry; |
|
5
|
|
|
use wapmorgan\UnifiedArchive\ArchiveInformation; |
|
6
|
|
|
use wapmorgan\UnifiedArchive\UnsupportedOperationException; |
|
7
|
|
|
|
|
8
|
|
|
abstract class BasicFormat |
|
9
|
|
|
{ |
|
10
|
|
|
/** |
|
11
|
|
|
* BasicFormat constructor. |
|
12
|
|
|
* @param string $archiveFileName |
|
13
|
|
|
*/ |
|
14
|
|
|
abstract public function __construct($archiveFileName); |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* Returns summary about an archive. |
|
18
|
|
|
* Called after |
|
19
|
|
|
* - constructing |
|
20
|
|
|
* - addFiles() |
|
21
|
|
|
* - deleteFiles() |
|
22
|
|
|
* @return ArchiveInformation |
|
23
|
|
|
*/ |
|
24
|
|
|
abstract public function getArchiveInformation(); |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* @return array |
|
28
|
|
|
*/ |
|
29
|
|
|
abstract public function getFileNames(); |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* @param string $fileName |
|
33
|
|
|
* @return bool |
|
34
|
|
|
*/ |
|
35
|
|
|
abstract public function isFileExists($fileName); |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* @param string $fileName |
|
39
|
|
|
* @return ArchiveEntry|false |
|
40
|
|
|
*/ |
|
41
|
|
|
abstract public function getFileData($fileName); |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* @param string $fileName |
|
45
|
|
|
* @return string|false |
|
46
|
|
|
*/ |
|
47
|
|
|
abstract public function getFileContent($fileName); |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* @param string $fileName |
|
51
|
|
|
* @return bool|resource|string |
|
52
|
|
|
*/ |
|
53
|
|
|
abstract public function getFileResource($fileName); |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* @param string $outputFolder |
|
57
|
|
|
* @param array $files |
|
58
|
|
|
* @return false|int Number of extracted files |
|
59
|
|
|
*/ |
|
60
|
|
|
abstract public function extractFiles($outputFolder, array $files); |
|
61
|
|
|
|
|
62
|
|
|
/** |
|
63
|
|
|
* @param string $outputFolder |
|
64
|
|
|
* @return false|int Number of extracted files |
|
65
|
|
|
*/ |
|
66
|
|
|
abstract public function extractArchive($outputFolder); |
|
67
|
|
|
|
|
68
|
|
|
/** |
|
69
|
|
|
* @param array $files |
|
70
|
|
|
* @return false|int Number of deleted files |
|
71
|
|
|
*/ |
|
72
|
|
|
abstract public function deleteFiles(array $files); |
|
73
|
|
|
|
|
74
|
|
|
/** |
|
75
|
|
|
* @param array $files |
|
76
|
|
|
* @return false|int Number of added files |
|
77
|
|
|
*/ |
|
78
|
|
|
abstract public function addFiles(array $files); |
|
79
|
|
|
|
|
80
|
|
|
/** |
|
81
|
|
|
* @param array $files |
|
82
|
|
|
* @param string $archiveFileName |
|
83
|
|
|
* |
|
84
|
|
|
* @return false|int Number of archived files |
|
85
|
|
|
* @throws UnsupportedOperationException |
|
86
|
|
|
*/ |
|
87
|
|
|
public static function createArchive(array $files, $archiveFileName) { |
|
|
|
|
|
|
88
|
|
|
throw new UnsupportedOperationException(); |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
/** |
|
92
|
|
|
* @return bool |
|
93
|
|
|
*/ |
|
94
|
|
|
public static function canAddFiles() |
|
95
|
|
|
{ |
|
96
|
|
|
return false; |
|
97
|
|
|
} |
|
98
|
|
|
|
|
99
|
|
|
/** |
|
100
|
|
|
* @return bool |
|
101
|
|
|
*/ |
|
102
|
|
|
public static function canDeleteFiles() |
|
103
|
|
|
{ |
|
104
|
|
|
return false; |
|
105
|
|
|
} |
|
106
|
|
|
} |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.