226 for($i = 0; $i < 1024; ++$i){
227 if($this->locationTable[$i][0] === 0 or $this->locationTable[$i][1] === 0){
230 fseek($this->filePointer, $this->locationTable[$i][0] << 12);
231 $chunk = fread($this->filePointer, $this->locationTable[$i][1] << 12);
234 $this->locationTable[$i] = [0, 0, 0];
238 $chunk = zlib_decode(substr($chunk, 5));
239 }
catch(\Throwable $e){
240 $this->locationTable[$i] = [0, 0, 0];
244 $chunk = chr(self::COMPRESSION_ZLIB) . zlib_encode($chunk, ZLIB_ENCODING_DEFLATE, 9);
246 $sectors = (int) ceil(strlen($chunk) / 4096);
247 if($sectors > $this->locationTable[$i][1]){
248 $this->locationTable[$i][0] = $this->lastSector + 1;
249 $this->lastSector += $sectors;
251 fseek($this->filePointer, $this->locationTable[$i][0] << 12);
252 fwrite($this->filePointer, str_pad($chunk, $sectors << 12,
"\x00", STR_PAD_RIGHT));
254 $this->writeLocationTable();
255 $n = $this->cleanGarbage();
256 $this->writeLocationTable();