1 | <?php |
||
29 | abstract class AbstractScanner { |
||
30 | |||
31 | /** |
||
32 | * Scan result |
||
33 | * @var Status |
||
34 | */ |
||
35 | protected $status; |
||
36 | |||
37 | /** |
||
38 | * If scanning was done part by part |
||
39 | * the first detected infected part is stored here |
||
40 | * @var Status |
||
41 | */ |
||
42 | protected $infectedStatus; |
||
43 | |||
44 | /** @var int */ |
||
45 | protected $byteCount; |
||
46 | |||
47 | /** @var resource */ |
||
48 | protected $writeHandle; |
||
49 | |||
50 | /** @var \OCA\Files_Antivirus\AppConfig */ |
||
51 | protected $appConfig; |
||
52 | |||
53 | /** @var string */ |
||
54 | protected $lastChunk; |
||
55 | |||
56 | /** @var bool */ |
||
57 | protected $isLogUsed = false; |
||
58 | |||
59 | /** @var bool */ |
||
60 | protected $isAborted = false; |
||
61 | |||
62 | /** |
||
63 | * Close used resources |
||
64 | */ |
||
65 | abstract protected function shutdownScanner(); |
||
66 | |||
67 | |||
68 | public function getStatus(){ |
||
77 | |||
78 | /** |
||
79 | * Synchronous scan |
||
80 | * @param IScannable $item |
||
81 | * @return Status |
||
82 | */ |
||
83 | public function scan(IScannable $item) { |
||
93 | |||
94 | /** |
||
95 | * Async scan - new portion of data is available |
||
96 | * @param string $data |
||
97 | */ |
||
98 | public function onAsyncData($data){ |
||
101 | |||
102 | /** |
||
103 | * Async scan - resource is closed |
||
104 | * @return Status |
||
105 | */ |
||
106 | public function completeAsyncScan(){ |
||
110 | |||
111 | /** |
||
112 | * Open write handle. etc |
||
113 | */ |
||
114 | public function initScanner(){ |
||
121 | |||
122 | /** |
||
123 | * @param string $chunk |
||
124 | */ |
||
125 | protected function writeChunk($chunk){ |
||
130 | |||
131 | /** |
||
132 | * @param string $data |
||
133 | */ |
||
134 | protected final function fwrite($data){ |
||
165 | |||
166 | /** |
||
167 | * @return bool |
||
168 | */ |
||
169 | protected function retry(){ |
||
176 | |||
177 | /** |
||
178 | * @param $data |
||
179 | * @return bool |
||
180 | */ |
||
181 | protected function writeRaw($data){ |
||
191 | |||
192 | /** |
||
193 | * Get a resource to write data into |
||
194 | * @return resource |
||
195 | */ |
||
196 | protected function getWriteHandle(){ |
||
199 | |||
200 | /** |
||
201 | * Prepare chunk (if required) |
||
202 | * @param string $data |
||
203 | * @return string |
||
204 | */ |
||
205 | protected function prepareChunk($data){ |
||
208 | } |
||
209 |