diff --git a/src/Chunk/AnvilChunk.php b/src/Chunk/AnvilChunk.php index b612127..b0c8b9f 100644 --- a/src/Chunk/AnvilChunk.php +++ b/src/Chunk/AnvilChunk.php @@ -2,6 +2,7 @@ namespace Aternos\Thanos\Chunk; +use Aternos\Thanos\Reader\CustomCompressionReader; use Aternos\Thanos\Reader\LZ4BlockReader; use Aternos\Thanos\Reader\RawReader; use Aternos\Thanos\Reader\ReaderInterface; @@ -142,6 +143,13 @@ public function __construct($file, int $offset, array $regionPosition, int $regi $dataLength ); break; + case 127: + $this->reader = new CustomCompressionReader( + $this->file, + $this->dataOffset, + $dataLength + ); + break; default: throw new Exception("Unknown chunk compression type."); } diff --git a/src/Reader/CustomCompressionReader.php b/src/Reader/CustomCompressionReader.php new file mode 100644 index 0000000..2725871 --- /dev/null +++ b/src/Reader/CustomCompressionReader.php @@ -0,0 +1,47 @@ +compressionType = $this->readCompressionType(); + throw new Exception("Unsupported custom compression type: " . $this->compressionType); + } + + /** + * @return string + * @throws Exception + */ + protected function readCompressionType(): string + { + $result = ""; + while ($char = $this->readRaw(1)) { + if (ord($char) !== 0) { + break; + } + $result .= $char; + } + return $result; + } + + /** + * @inheritDoc + * @throws Exception + */ + protected function getRawChunk(int $length): string + { + return $this->readRaw($length); + } +}